Submission #198601

# Submission time Handle Problem Language Result Execution time Memory
198601 2020-01-26T19:48:16 Z ZwariowanyMarcin Vođe (COCI17_vode) C++14
120 / 120
239 ms 504 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define ss(x) (int) x.size()
#define pb push_back
#define LL long long
#define ld long double
#define cat(x) cerr << #x << " = " << x << endl
#define FOR(i, j, n) for(int i = j; i <= n; ++i)
#define boost cin.tie(0), ios_base::sync_with_stdio(0);


using namespace std;		

const int nax = 5010;
const int INF = 1e9 + 111;

int n, m, k;
int a[nax];
int win[nax];
int lose[nax];
int dp[nax];

int main() {
	scanf ("%d%d%d", &n, &m, &k);
	for (int i = 0; i < n; ++i) {
		scanf ("%d", a + i);
		win[i] = INF;
		lose[i] = m - 1;
	}
	
	for (int i = m - 2; 0 <= i; --i) {
		for (int j = 0; j < n; ++j) {
			int g = (j + 1) % n;
			if (a[j] == a[g]) {
				if (win[g] <= i + k) {
					dp[j] = 1;
				}
				else {
					dp[j] = 0;
				}
			}
			else {
				if (lose[g] <= i + k) {
					dp[j] = 1;
				}
				else {
					dp[j] = 0;
				}
			}
		}
		for (int j = 0; j < n; ++j) {
			if (dp[j]) win[j] = i;
			else lose[j] = i;
		}
	}
	
	for (int i = 0; i < n; ++i) {
		if ((a[i] == 0 && dp[i] == 1) || (a[i] == 1 && dp[i] == 0))
			printf ("0 ");
		else 
			printf ("1 ");
	}
				
	
	
	return 0;
}

Compilation message

vode.cpp: In function 'int main()':
vode.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d%d%d", &n, &m, &k);
  ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
vode.cpp:28:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%d", a + i);
   ~~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 504 KB Output is correct
2 Correct 32 ms 376 KB Output is correct
3 Correct 221 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 504 KB Output is correct
2 Correct 193 ms 504 KB Output is correct
3 Correct 78 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 238 ms 444 KB Output is correct
2 Correct 8 ms 376 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 239 ms 448 KB Output is correct
2 Correct 218 ms 504 KB Output is correct
3 Correct 165 ms 376 KB Output is correct