Submission #488523

# Submission time Handle Problem Language Result Execution time Memory
488523 2021-11-19T12:57:01 Z rainboy Kamenčići (COCI21_kamencici) C
70 / 70
50 ms 85924 KB
#include <stdio.h>

#define N	350

int main() {
	static char cc[N + 1];
	static int pp[N], dp[N][N + 1][N];
	int n, k_, i, j, k;

	scanf("%d%d%s", &n, &k_, cc);
	for (i = 0; i < n; i++)
		pp[i] = cc[i] == 'C' ? 1 : 0;
	for (i = 1; i < n; i++)
		pp[i] += pp[i - 1];
	for (i = n - 1; i >= 0; i--)
		for (j = i; j <= n; j++) {
			int c = (i == 0 ? 0 : pp[i - 1]) + pp[n - 1] - (j == 0 ? 0 : pp[j - 1]);

			for (k = 0; k < k_; k++)
				dp[i][j][k] = c - k >= k_ ? 1 : !(dp[i + 1][j][c - k] && dp[i][j - 1][c - k]);
		}
	printf(dp[0][n][0] ? "DA\n" : "NE\n");
	return 0;
}

Compilation message

Main.c: In function 'main':
Main.c:10:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d%d%s", &n, &k_, cc);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 0 ms 588 KB Output is correct
3 Correct 0 ms 588 KB Output is correct
4 Correct 0 ms 588 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 0 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 0 ms 588 KB Output is correct
3 Correct 0 ms 588 KB Output is correct
4 Correct 0 ms 588 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 0 ms 588 KB Output is correct
7 Correct 1 ms 2252 KB Output is correct
8 Correct 1 ms 1868 KB Output is correct
9 Correct 1 ms 2200 KB Output is correct
10 Correct 1 ms 1868 KB Output is correct
11 Correct 1 ms 1868 KB Output is correct
12 Correct 2 ms 2052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 0 ms 588 KB Output is correct
3 Correct 0 ms 588 KB Output is correct
4 Correct 0 ms 588 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 0 ms 588 KB Output is correct
7 Correct 1 ms 2252 KB Output is correct
8 Correct 1 ms 1868 KB Output is correct
9 Correct 1 ms 2200 KB Output is correct
10 Correct 1 ms 1868 KB Output is correct
11 Correct 1 ms 1868 KB Output is correct
12 Correct 2 ms 2052 KB Output is correct
13 Correct 39 ms 85924 KB Output is correct
14 Correct 47 ms 85452 KB Output is correct
15 Correct 33 ms 77548 KB Output is correct
16 Correct 42 ms 84628 KB Output is correct
17 Correct 50 ms 85156 KB Output is correct
18 Correct 39 ms 84628 KB Output is correct