Submission #237136

# Submission time Handle Problem Language Result Execution time Memory
237136 2020-06-04T17:58:51 Z Vimmer Vođe (COCI17_vode) C++14
120 / 120
561 ms 96596 KB
#include <bits/stdc++.h>

using namespace std;

int a[5005], f[5005][5005];

int main()
{
    int n, m, k;

	cin >> n >> m >> k;

	for (int i = 0; i < n; i++) cin >> a[i];

	for (int i = 0; i < n; i++) f[(i + 1) % n][m] = (a[i] != a[(i + 1) % n]);

	for (int j = m - 1; j >= 0; j--)
	for (int i = 0; i < n; i++)
	{
		int nxt = (i + 1) % n, l = j + 1, r = min(j + k, m);

        bool val = 0;

		f[i][j] = f[i][j + 1];

		if (a[i] != a[nxt]) val = ((f[nxt][l] - f[nxt][r + 1]) != (r - l + 1));

		if (a[i] == a[nxt]) val = ((f[nxt][l] - f[nxt][r + 1]) > 0);

		f[i][j] += val;
	}

	for (int i = 0; i < n; i++)
        if (f[i][1] != f[i][0]) cout << a[i] << " "; else cout << (1 + a[i]) % 2 << " ";
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 640 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1408 KB Output is correct
2 Correct 5 ms 768 KB Output is correct
3 Correct 5 ms 1408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1536 KB Output is correct
2 Correct 5 ms 1408 KB Output is correct
3 Correct 6 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2048 KB Output is correct
2 Correct 6 ms 2432 KB Output is correct
3 Correct 6 ms 2304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 3072 KB Output is correct
2 Correct 7 ms 2816 KB Output is correct
3 Correct 7 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2688 KB Output is correct
2 Correct 7 ms 2816 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 19192 KB Output is correct
2 Correct 66 ms 20856 KB Output is correct
3 Correct 453 ms 94676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 126 ms 38368 KB Output is correct
2 Correct 399 ms 94504 KB Output is correct
3 Correct 126 ms 41080 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 495 ms 95480 KB Output is correct
2 Correct 9 ms 2560 KB Output is correct
3 Correct 7 ms 1664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 462 ms 96096 KB Output is correct
2 Correct 338 ms 96248 KB Output is correct
3 Correct 561 ms 96596 KB Output is correct