Submission #36621516
Source Code Expand
Copy
#include<bits/stdc++.h>using namespace std;typedef long double ld;typedef long long ll;typedef unsigned long long ull;#define pii pair<int,int>#define pll pair<ll,ll>#define pld pair<ld,ld>#define pb push_back#define fi first#define se second#define UP(a,b,c) for(int a=b;a<c;++a)#define UU(a,b,c) for(int a=b;a<=c;++a)#define DN(a,b,c) for(int a=b;a>c;--a)#define DU(a,b,c) for(int a=b;a>=c;--a)#define lc(i) (i+1)#define rc(i) (i+(m-l+1)*2)#define debug(x) cout << #x << " = " << x << endl;template<class A, class B>ostream& operator<<(ostream& os, const pair<A, B> &p) {
#include<bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; typedef unsigned long long ull; #define pii pair<int,int> #define pll pair<ll,ll> #define pld pair<ld,ld> #define pb push_back #define fi first #define se second #define UP(a,b,c) for(int a=b;a<c;++a) #define UU(a,b,c) for(int a=b;a<=c;++a) #define DN(a,b,c) for(int a=b;a>c;--a) #define DU(a,b,c) for(int a=b;a>=c;--a) #define lc(i) (i+1) #define rc(i) (i+(m-l+1)*2) #define debug(x) cout << #x << " = " << x << endl; template<class A, class B> ostream& operator<<(ostream& os, const pair<A, B> &p) { os << '(' << p.first << ',' << p.second << ')'; return os; } template<class T> ostream& operator<<(ostream& os, const vector<T> &v) { bool fs = 1; os << '{'; for(auto &i : v) { if(!fs) os << ", "; os << i; fs = 0; } os << '}'; return os; } ll expo(ll a, ll b, const int MOD) { ll ans = 1; for(; b ; b>>=1, a=a*a%MOD) if(b&1) ans=ans*a%MOD; return ans; } ll inv(ll x, const int MOD) { return expo(x, MOD-2, MOD); } const int R = 3e2; const int C = 3e2; int r, c, cnt[R*C+5], g[R+5][C+5], n, h, w, num, ans[R+5][C+5]; void add(int x) { if(!cnt[x]) ++num; ++cnt[x]; } void rem(int x) { --cnt[x]; if(!cnt[x]) --num; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> r >> c >> n >> h >> w; for(int j = 1 ; j <= r ; ++j) { for(int i = 1 ; i <= c ; ++i) { cin >> g[j][i]; if(j > h || i > w) add(g[j][i]); } } int np = 0; for(int j = 1 ; j <= r-h+1 ; ++j) { int x = (j&1 ? 1 : -1); for(int i = (j&1 ? 1 : c-w+1) ; 1 <= i && i <= c-w+1 ; i += x) { ++np; // cout << j << " " << i << " = "; for(int k = 1 ; k <= n ; ++k) cout << cnt[k] << " "; cout << endl; ans[j][i] = num; for(int k = (np == c-w+1 ? w : h) - 1 ; ~k ; --k) { if(np == c-w+1) { add(g[j][i+k]); rem(g[j+h][i+k]); } else { add(g[j+k][i+(x==1?0:w-1)]); rem(g[j+k][i+(x==1?w:-1)]); } } np %= c-w+1; } } for(int j = 1 ; j <= r-h+1 ; ++j) for(int i = 1 ; i <= c-w+1 ; ++i) cout << ans[j][i] << (" \n"[i == c-w+1]); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Grid Filling |
User | kresna |
Language | C++ (GCC 9.2.1) |
Score | 500 |
Code Size | 2492 Byte |
Status | AC |
Exec Time | 37 ms |
Memory | 4288 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:92:39: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 92 | for(int j = 1 ; j <= r-h+1 ; ++j) for(int i = 1 ; i <= c-w+1 ; ++i) | ^~~ ./Main.cpp:95:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 95 | return 0; | ^~~~~~
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 03_max_12.txt, 03_max_13.txt, 03_max_14.txt, 03_max_15.txt, 04_edge_16.txt, 04_edge_17.txt, 04_edge_18.txt, 04_edge_19.txt, 04_edge_20.txt, 04_edge_21.txt, 04_edge_22.txt, 04_edge_23.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 7 ms | 3488 KB |
00_sample_01.txt | AC | 2 ms | 3476 KB |
00_sample_02.txt | AC | 2 ms | 3512 KB |
01_small_03.txt | AC | 2 ms | 3492 KB |
01_small_04.txt | AC | 2 ms | 3508 KB |
01_small_05.txt | AC | 3 ms | 3504 KB |
02_random_06.txt | AC | 2 ms | 3668 KB |
02_random_07.txt | AC | 19 ms | 4004 KB |
02_random_08.txt | AC | 2 ms | 3472 KB |
02_random_09.txt | AC | 2 ms | 3440 KB |
02_random_10.txt | AC | 3 ms | 3504 KB |
02_random_11.txt | AC | 3 ms | 3784 KB |
03_max_12.txt | AC | 37 ms | 3936 KB |
03_max_13.txt | AC | 24 ms | 4200 KB |
03_max_14.txt | AC | 34 ms | 4088 KB |
03_max_15.txt | AC | 19 ms | 3948 KB |
04_edge_16.txt | AC | 20 ms | 4184 KB |
04_edge_17.txt | AC | 16 ms | 4220 KB |
04_edge_18.txt | AC | 18 ms | 3892 KB |
04_edge_19.txt | AC | 13 ms | 3980 KB |
04_edge_20.txt | AC | 21 ms | 4288 KB |
04_edge_21.txt | AC | 18 ms | 4220 KB |
04_edge_22.txt | AC | 20 ms | 3844 KB |
04_edge_23.txt | AC | 18 ms | 3928 KB |