Submission #199954

#TimeUsernameProblemLanguageResultExecution timeMemory
199954Osama_AlkhodairyVođe (COCI17_vode)C++17
120 / 120
1127 ms96632 KiB
#include <bits/stdc++.h> using namespace std; #define finish(x) return cout << x << endl, 0 #define ll long long const int N = 5001; int n, m, k, dp[N][N], cnt[N][2]; vector <int> a; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m >> k; a.resize(n); for(auto &i : a) cin >> i; for(int i = 0 ; i < n ; i++){ cnt[i][0] = 1; } for(int c = m - 1 ; c >= 1 ; c--){ for(int i = 0 ; i < n ; i++){ if(c + k + 1 <= m){ cnt[i][dp[i][c + k + 1]]--; } } for(int i = 0 ; i < n ; i++){ int g = (i + 1) % n; //~ for(int j = c + 1 ; j <= min(m, c + k) ; j++){ //~ if(a[i] == a[g] && dp[g][j]) dp[i][c] = 1; //~ if(a[i] != a[g] && dp[g][j] == 0) dp[i][c] = 1; //~ } if(a[i] == a[g]) dp[i][c] = (bool)cnt[g][1]; else dp[i][c] = (bool)cnt[g][0]; } for(int i = 0 ; i < n ; i++){ cnt[i][dp[i][c]]++; } } for(int i = 0 ; i < n ; i++){ cout << (dp[i][1] ^ a[i] ^ 1) << " "; } cout << endl; }
#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...