Submission #217294

#TimeUsernameProblemLanguageResultExecution timeMemory
217294quocnguyen1012Vođe (COCI17_vode)C++14
120 / 120
798 ms96636 KiB
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back #define eb emplace_back using namespace std; typedef long long ll; typedef pair<int, int> ii; const int maxn = 5e3 + 5; int f[maxn][maxn], num[2][maxn], a[maxn]; int N, M, K; signed main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef LOCAL freopen("A.INP", "r", stdin); freopen("A.OUT", "w", stdout); #endif // LOCAL cin >> N >> M >> K; for(int i = 1; i <= N; ++i){ cin >> a[i]; f[i][M - 1] = a[i] ^ 1; num[a[i] ^ 1][i]++; } for(int j = M - 2; j >= 0; --j){ for(int i = 1; i <= N; ++i){ int nxt = i + 1; if(nxt > N) nxt -= N; if(num[a[i]][nxt]) f[i][j] = a[i]; else f[i][j] = a[i] ^ 1; } for(int i = 1; i <= N; ++i){ num[f[i][j]][i]++; if(j + K < M) num[f[i][j + K]][i]--; } } for(int i = 1; i <= N; ++i) cout << f[i][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...