This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 = int(2e9);
const ll OO = 1e18;
const int md = int(1e9) + 7;
int mem[N][N], net[N], tp[N], n, m, k;
int get(int ps, int vl){
if (mem[ps][vl] > 0) return mem[ps][vl] - 1;
int res = 0;
if (tp[net[ps]] == tp[ps]){
for (int nw = min(vl + k, m - 1); nw > vl && res == 0; nw--)
if (get(net[ps], nw) == 1)
res = 1;
} else {
for (int nw = min(vl + k, m - 1); nw > vl && res == 0; nw--)
if (get(net[ps], nw) == 0)
res = 1;
}
mem[ps][vl] = res + 1;
return res;
}
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];
net[i] = (i + 1) % n;
}
for (int i = 0; i < n; i++){
int ans = 0;
ans = get(i, 0);
cout << (tp[i] ^ ans ^ 1) << " ";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |