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 <iostream>
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
using namespace std;
int n, m, k, nt[5000][5001];
bool sg[5000], dp[5000][5000]; //n, m
int main() {
ios_base::sync_with_stdio(false);
cin >> n >> m >> k;
for (int i = 0; i < n; i++){
cin >> sg[i];
}
for (int i = 0; i < n; i++){
dp[i][m-1] = !sg[i]; nt[i][m] = 0; nt[i][m-1] = !sg[i];
}
for (int i = m-2; i >= 0; i--){
for (int j = 0; j < n; j++){
int is = i+1, ie = min(m, i+k+1), il = ie-is, nv = (j+1) % n, itn = nt[nv][is]-nt[nv][ie];
if (sg[j]){
dp[j][i] = true;
if (itn == 0){
dp[j][i] = false;
}
} else {
dp[j][i] = false;
if (itn == il){
dp[j][i] = true;
}
}
nt[j][i] = nt[j][i+1]+dp[j][i];
}
}
for (int i = 0; i < n; i++){
cout << dp[i][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... |