1 solutions
-
0
#include <bits/stdc++.h> using namespace std; #define accelerate ios::sync_with_stdio(false),cin.tie(0); #define int long long #define LL long long #define PII pair<int,int> #define INF 0x3f3f3f3f #define ufor(i,st,en) for(int i=st;i<=en;i++) #define dfor(i,en,st) for(int i=en;i>=st;i--) const int N=2e5+100; int n,m,k,x,y,T,q,b; int a[305][305][305]; signed main(){ accelerate; int H,W,h,w; cin>>H>>W>>n>>h>>w; ufor(i,1,H){ ufor(j,1,W){ cin>>x; a[x][i][j]++; } } ufor(x,1,n){ ufor(i,1,H){ ufor(j,1,W){ a[x][i][j]+=a[x][i-1][j]+a[x][i][j-1]-a[x][i-1][j-1]; } } } for(int i=1;i+h-1<=H;i++){ for(int j=1;j+w-1<=W;j++){ int ans=0; ufor(k,1,n){ int cnt=a[k][H][W]-a[k][i+h-1][j+w-1]+a[k][i+h-1][j-1]+a[k][i-1][j+w-1]-a[k][i-1][j-1]; ans+=cnt>0; } printf("%lld%c",ans," \n"[j+w-1==W]); } } return 0; }
- 1
Information
- ID
- 6681
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 7
- Tags
- (None)
- # Submissions
- 16
- Accepted
- 5
- Uploaded By