Submission #236769

#TimeUsernameProblemLanguageResultExecution timeMemory
236769VEGAnnVođe (COCI17_vode)C++14
120 / 120
697 ms94416 KiB
#include <bits/stdc++.h> #define sz(x) ((int)x.size()) #define ft first #define sd second using namespace std; typedef long long ll; const int N = 5010; const int oo = 2e9; const ll OO = 1e18; const int md = int(1e9) + 7; short tp[N], pre[N], net[N], vl[2][N], ad[2][N][N], n, m, k; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifdef _LOCAL freopen("in.txt","r",stdin); #endif // _LOCAL cin >> n >> m >> k; k = min(m, k); for (int i = 0; i < n; i++) { cin >> tp[i]; pre[i] = (i - 1 + n) % n; net[i] = (i + 1) % n; } if (m == 1){ for (int i = 0; i < n; i++) cout << (tp[i] ^ 1) << " "; return 0; } for (int i = 0; i < n; i++){ int rt = m - 2; int lf = max(0, m - 1 - k); ad[0][pre[i]][rt]++; if (lf > 0) ad[0][pre[i]][lf - 1]--; } for (int j = m - 2; j >= 0; j--){ for (int i = 0; i < n; i++){ vl[0][i] += ad[0][i][j]; vl[1][i] += ad[1][i][j]; int typ = 0; if (tp[net[i]] == tp[i]){ if (vl[1][i] > 0) typ = 1; } else { if (vl[0][i] > 0) typ = 1; } if (j == 0) cout << (tp[i] ^ 1 ^ typ) << " "; else { int rt = j - 1; int lf = max(0, j - k); ad[typ][pre[i]][rt]++; if (lf > 0) ad[typ][pre[i]][lf - 1]--; } } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...