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>
using namespace std;
const int maxn = 5e3 + 500;
int dp[maxn][maxn];
int num[2][maxn];
int ani[maxn];
int main() {
int n, m, k;
cin >> n >> m >> k;
for (int i = 0; i < n; i++)
cin >> ani[i]; // 0 is a sheep, 1 is a goat
for (int i = 0; i < n; i++){
dp[i][m - 1] = (ani[i] ^ 1);
num[ani[i] ^ 1][i] ++;
}
for (int j = m - 2; j >= 0; j--){
for (int i = 0; i < n; i++){
int nex = (i + 1) % n;
if (num[ani[i]][nex])
dp[i][j] = ani[i];
else
dp[i][j] = ani[i] ^ 1;
// cout << i << " " << j << " " << dp[i][j] << endl;
}
for (int i = 0; i < n; i++){
num[dp[i][j]][i] ++;
if (j + k < m)
num[dp[i][j + k]][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... |