답안 #471736

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
471736 2021-09-10T15:00:11 Z rainboy Vođe (COCI17_vode) C
120 / 120
173 ms 452 KB
#include <stdio.h>
#include <string.h>

#define N	5000
#define M	5000

int main() {
	static int cc[N], dp[N], dq[N], dp_[N], dq_[N];
	int n, m, k, i, j;

	scanf("%d%d%d", &n, &m, &k);
	for (i = 0; i < n; i++)
		scanf("%d", &cc[i]);
	for (i = 0; i < n; i++)
		dp[i] = cc[i] ^ 1, dq[i] = m;
	for (j = m - 2; j >= 0; j--) {
		for (i = 0; i < n; i++) {
			dp_[i] = cc[i] ^ (dp[(i + 1) % n] == cc[i] || dq[(i + 1) % n] != m && dq[(i + 1) % n] - j <= k ? 0 : 1);
			dq_[i] = dp_[i] == dp[i] ? dq[i] : j + 1;
		}
		memcpy(dp, dp_, n * sizeof *dp_);
		memcpy(dq, dq_, n * sizeof *dq_);
	}
	for (i = 0; i < n; i++)
		printf("%d ", dp[i]);
	printf("\n");
	return 0;
}

Compilation message

vode.c: In function 'main':
vode.c:18:71: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   18 |    dp_[i] = cc[i] ^ (dp[(i + 1) % n] == cc[i] || dq[(i + 1) % n] != m && dq[(i + 1) % n] - j <= k ? 0 : 1);
      |                                                  ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
vode.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d%d%d", &n, &m, &k);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
vode.c:13:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%d", &cc[i]);
      |   ^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 0 ms 276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 324 KB Output is correct
2 Correct 22 ms 316 KB Output is correct
3 Correct 152 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 332 KB Output is correct
2 Correct 148 ms 364 KB Output is correct
3 Correct 56 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 173 ms 364 KB Output is correct
2 Correct 4 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 171 ms 368 KB Output is correct
2 Correct 162 ms 372 KB Output is correct
3 Correct 157 ms 452 KB Output is correct