Submission #236801

#TimeUsernameProblemLanguageResultExecution timeMemory
236801NONAMEVođe (COCI17_vode)C++17
120 / 120
553 ms96696 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; const int N = 5e3 + 10; int n, m, k, a[N], f[N][N]; int main() { cin >> n >> m >> k; for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < n; ++i) f[(i + 1) % n][m] = (a[i] != a[(i + 1) % n]); for (int j = m - 1; j >= 0; --j) for (int i = 0; i < n; ++i) { int nxt = (i + 1) % n; int l = j + 1, r = min(j + k, m); bool gd = 0; f[i][j] = f[i][j + 1]; if (a[i] != a[nxt]) gd = ((f[nxt][l] - f[nxt][r + 1]) != (r - l + 1)); if (a[i] == a[nxt]) gd = ((f[nxt][l] - f[nxt][r + 1]) > 0); /* if (a[i] != a[nxt]) { for (int l = j + 1; l <= min(j + k, m); ++l) gd |= !(f[nxt][l]); } else { for (int l = j + 1; l <= min(j + k, m); ++l) gd |= f[nxt][l]; } */ f[i][j] += gd; } for (int i = 0; i < n; ++i) cout << (f[i][0] != f[i][1] ? a[i] : a[i] ^ 1) << ' '; }
#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...