Submission #40393

#TimeUsernameProblemLanguageResultExecution timeMemory
40393szawinisVođe (COCI17_vode)C++14
120 / 120
2383 ms97392 KiB
#include <bits/stdc++.h> using namespace std; const int N = 5010; struct fenwick { int f[N]; void update(int i, int v) { ++i; while(i < N) f[i] += v, i += i & -i; } int query(int i) { ++i; int ret = 0; while(i > 0) ret += f[i], i -= i & -i; return ret; } int query(int l, int r) { return query(r) - query(l-1); } }; int n, m, k; bool state[N]; fenwick dp[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m >> k; for(int i = 0; i < n; i++) cin >> state[i]; for(int j = m-1; j >= 1; j--) for(int i = n-1; i >= 0; i--) { if(state[(i+1) % n] == state[i]) dp[i].update(j, dp[(i+1) % n].query(min(m, j+1), min(m, j+k)) > 0); else dp[i].update(j, dp[(i+1) % n].query(min(m, j+1), min(m, j+k)) == 0); } for(int i = 0; i < n; i++) { bool res = 0; for(int j = 1; j <= min(m-1, k); j++) res |= dp[i].query(j, j) == 1; cout << (res ^ 1 ^ state[i]) << ' '; } }
#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...