# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
500990 | 2022-01-01T22:03:16 Z | rainboy | Wells (CEOI21_wells) | C | 1 ms | 588 KB |
#include <stdio.h> #include <stdlib.h> #include <string.h> #define N 200 #define INF 0x3f3f3f3f3f3f3f3fLL long long min(long long a, long long b) { return a < b ? a : b; } int max(int a, int b) { return a > b ? a : b; } int *ej[N], eo[N], n, k; void append(int i, int j) { int o = eo[i]++; if (o >= 2 && (o & o - 1) == 0) ej[i] = (int *) realloc(ej[i], o * 2 * sizeof *ej[i]); ej[i][o] = j; } long long ww[N]; int dfs1(int p, int i, int d) { int o, w; if (--d == 0) { ww[i]++; return 1; } w = 0; for (o = eo[i]; o--; ) { int j = ej[i][o]; if (j != p) w += dfs1(i, j, d); } ww[i] += w; return w; } long long dp[N][N + 1]; int sz[N + 1]; void dfs2(int p, int i) { int o, di, dj; dp[i][0] = ww[i], dp[i][1] = 0, sz[i] = 1; for (o = eo[i]; o--; ) { int j = ej[i][o]; if (j != p) { dfs2(i, j); memset(dp[i] + sz[i] + 1, INF, sz[j] * sizeof *dp[i]); for (di = sz[i]; di >= 0; di--) { long long x = dp[i][di]; dp[i][di] = INF; for (dj = sz[j]; dj >= 0; dj--) { long long y = dp[j][dj]; if (di + dj < k) { int d = di == 0 ? 0 : max(di, dj + 1); dp[i][d] = min(dp[i][d], x + y); } } } sz[i] += sz[j]; } } } int main() { int h, i, j, d; long long w; scanf("%d%d", &n, &k); for (i = 0; i < n; i++) ej[i] = (int *) malloc(2 * sizeof *ej[i]); for (h = 0; h < n - 1; h++) { scanf("%d%d", &i, &j), i--, j--; append(i, j), append(j, i); } for (i = 0; i < n; i++) dfs1(-1, i, k); w = 0; for (i = 0; i < n; i++) w += ww[i] /= 2; w /= k; dfs2(-1, 0); for (d = 0; d < n; d++) if (dp[0][d] == w) { printf("YES\n"); printf("0\n"); return 0; } printf("NO\n"); printf("0\n"); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 0 ms | 204 KB | Output is partially correct |
2 | Partially correct | 1 ms | 588 KB | Output is partially correct |
3 | Partially correct | 1 ms | 588 KB | Output is partially correct |
4 | Partially correct | 1 ms | 588 KB | Output is partially correct |
5 | Partially correct | 1 ms | 588 KB | Output is partially correct |
6 | Partially correct | 1 ms | 588 KB | Output is partially correct |
7 | Correct | 1 ms | 588 KB | Output is correct |
8 | Partially correct | 1 ms | 588 KB | Output is partially correct |
9 | Partially correct | 1 ms | 588 KB | Output is partially correct |
10 | Correct | 1 ms | 588 KB | Output is correct |
11 | Partially correct | 1 ms | 588 KB | Output is partially correct |
12 | Partially correct | 1 ms | 544 KB | Output is partially correct |
13 | Partially correct | 0 ms | 588 KB | Output is partially correct |
14 | Partially correct | 1 ms | 588 KB | Output is partially correct |
15 | Partially correct | 1 ms | 588 KB | Output is partially correct |
16 | Partially correct | 1 ms | 588 KB | Output is partially correct |
17 | Partially correct | 1 ms | 588 KB | Output is partially correct |
18 | Partially correct | 1 ms | 588 KB | Output is partially correct |
19 | Partially correct | 1 ms | 588 KB | Output is partially correct |
20 | Correct | 1 ms | 588 KB | Output is correct |
21 | Partially correct | 1 ms | 536 KB | Output is partially correct |
22 | Partially correct | 1 ms | 588 KB | Output is partially correct |
23 | Partially correct | 1 ms | 588 KB | Output is partially correct |
24 | Partially correct | 1 ms | 588 KB | Output is partially correct |
25 | Partially correct | 1 ms | 588 KB | Output is partially correct |
26 | Partially correct | 1 ms | 588 KB | Output is partially correct |
27 | Partially correct | 1 ms | 540 KB | Output is partially correct |
28 | Correct | 1 ms | 588 KB | Output is correct |
29 | Partially correct | 0 ms | 588 KB | Output is partially correct |
30 | Partially correct | 1 ms | 588 KB | Output is partially correct |
31 | Partially correct | 1 ms | 588 KB | Output is partially correct |
32 | Correct | 1 ms | 588 KB | Output is correct |
33 | Partially correct | 0 ms | 588 KB | Output is partially correct |
34 | Correct | 1 ms | 588 KB | Output is correct |
35 | Partially correct | 1 ms | 588 KB | Output is partially correct |
36 | Partially correct | 1 ms | 536 KB | Output is partially correct |
37 | Partially correct | 1 ms | 588 KB | Output is partially correct |
38 | Partially correct | 1 ms | 540 KB | Output is partially correct |
39 | Partially correct | 1 ms | 528 KB | Output is partially correct |
40 | Partially correct | 1 ms | 588 KB | Output is partially correct |
41 | Partially correct | 1 ms | 588 KB | Output is partially correct |
42 | Partially correct | 1 ms | 588 KB | Output is partially correct |
43 | Partially correct | 1 ms | 588 KB | Output is partially correct |
44 | Correct | 1 ms | 588 KB | Output is correct |
45 | Partially correct | 1 ms | 588 KB | Output is partially correct |
46 | Partially correct | 1 ms | 588 KB | Output is partially correct |
47 | Partially correct | 1 ms | 540 KB | Output is partially correct |
48 | Partially correct | 1 ms | 588 KB | Output is partially correct |
49 | Partially correct | 1 ms | 588 KB | Output is partially correct |
50 | Partially correct | 1 ms | 588 KB | Output is partially correct |
51 | Partially correct | 1 ms | 540 KB | Output is partially correct |
52 | Partially correct | 1 ms | 588 KB | Output is partially correct |
53 | Partially correct | 1 ms | 588 KB | Output is partially correct |
54 | Partially correct | 1 ms | 588 KB | Output is partially correct |
55 | Partially correct | 1 ms | 588 KB | Output is partially correct |
56 | Correct | 1 ms | 556 KB | Output is correct |
57 | Partially correct | 1 ms | 588 KB | Output is partially correct |
58 | Correct | 1 ms | 588 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 0 ms | 204 KB | Output is partially correct |
2 | Partially correct | 1 ms | 588 KB | Output is partially correct |
3 | Partially correct | 1 ms | 588 KB | Output is partially correct |
4 | Partially correct | 1 ms | 588 KB | Output is partially correct |
5 | Partially correct | 1 ms | 588 KB | Output is partially correct |
6 | Partially correct | 1 ms | 588 KB | Output is partially correct |
7 | Correct | 1 ms | 588 KB | Output is correct |
8 | Partially correct | 1 ms | 588 KB | Output is partially correct |
9 | Partially correct | 1 ms | 588 KB | Output is partially correct |
10 | Correct | 1 ms | 588 KB | Output is correct |
11 | Partially correct | 1 ms | 588 KB | Output is partially correct |
12 | Partially correct | 1 ms | 544 KB | Output is partially correct |
13 | Partially correct | 0 ms | 588 KB | Output is partially correct |
14 | Partially correct | 1 ms | 588 KB | Output is partially correct |
15 | Partially correct | 1 ms | 588 KB | Output is partially correct |
16 | Partially correct | 1 ms | 588 KB | Output is partially correct |
17 | Partially correct | 1 ms | 588 KB | Output is partially correct |
18 | Partially correct | 1 ms | 588 KB | Output is partially correct |
19 | Partially correct | 1 ms | 588 KB | Output is partially correct |
20 | Correct | 1 ms | 588 KB | Output is correct |
21 | Partially correct | 1 ms | 536 KB | Output is partially correct |
22 | Partially correct | 1 ms | 588 KB | Output is partially correct |
23 | Partially correct | 1 ms | 588 KB | Output is partially correct |
24 | Partially correct | 1 ms | 588 KB | Output is partially correct |
25 | Partially correct | 1 ms | 588 KB | Output is partially correct |
26 | Partially correct | 1 ms | 588 KB | Output is partially correct |
27 | Partially correct | 1 ms | 540 KB | Output is partially correct |
28 | Correct | 1 ms | 588 KB | Output is correct |
29 | Partially correct | 0 ms | 588 KB | Output is partially correct |
30 | Partially correct | 1 ms | 588 KB | Output is partially correct |
31 | Partially correct | 1 ms | 588 KB | Output is partially correct |
32 | Correct | 1 ms | 588 KB | Output is correct |
33 | Partially correct | 0 ms | 588 KB | Output is partially correct |
34 | Correct | 1 ms | 588 KB | Output is correct |
35 | Partially correct | 1 ms | 588 KB | Output is partially correct |
36 | Partially correct | 1 ms | 536 KB | Output is partially correct |
37 | Partially correct | 1 ms | 588 KB | Output is partially correct |
38 | Partially correct | 1 ms | 540 KB | Output is partially correct |
39 | Partially correct | 1 ms | 528 KB | Output is partially correct |
40 | Partially correct | 1 ms | 588 KB | Output is partially correct |
41 | Partially correct | 1 ms | 588 KB | Output is partially correct |
42 | Partially correct | 1 ms | 588 KB | Output is partially correct |
43 | Partially correct | 1 ms | 588 KB | Output is partially correct |
44 | Correct | 1 ms | 588 KB | Output is correct |
45 | Partially correct | 1 ms | 588 KB | Output is partially correct |
46 | Partially correct | 1 ms | 588 KB | Output is partially correct |
47 | Partially correct | 1 ms | 540 KB | Output is partially correct |
48 | Partially correct | 1 ms | 588 KB | Output is partially correct |
49 | Partially correct | 1 ms | 588 KB | Output is partially correct |
50 | Partially correct | 1 ms | 588 KB | Output is partially correct |
51 | Partially correct | 1 ms | 540 KB | Output is partially correct |
52 | Partially correct | 1 ms | 588 KB | Output is partially correct |
53 | Partially correct | 1 ms | 588 KB | Output is partially correct |
54 | Partially correct | 1 ms | 588 KB | Output is partially correct |
55 | Partially correct | 1 ms | 588 KB | Output is partially correct |
56 | Correct | 1 ms | 556 KB | Output is correct |
57 | Partially correct | 1 ms | 588 KB | Output is partially correct |
58 | Correct | 1 ms | 588 KB | Output is correct |
59 | Correct | 0 ms | 204 KB | Output is correct |
60 | Runtime error | 1 ms | 460 KB | Execution killed with signal 11 |
61 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 0 ms | 204 KB | Output is partially correct |
2 | Partially correct | 1 ms | 588 KB | Output is partially correct |
3 | Partially correct | 1 ms | 588 KB | Output is partially correct |
4 | Partially correct | 1 ms | 588 KB | Output is partially correct |
5 | Partially correct | 1 ms | 588 KB | Output is partially correct |
6 | Partially correct | 1 ms | 588 KB | Output is partially correct |
7 | Correct | 1 ms | 588 KB | Output is correct |
8 | Partially correct | 1 ms | 588 KB | Output is partially correct |
9 | Partially correct | 1 ms | 588 KB | Output is partially correct |
10 | Correct | 1 ms | 588 KB | Output is correct |
11 | Partially correct | 1 ms | 588 KB | Output is partially correct |
12 | Partially correct | 1 ms | 544 KB | Output is partially correct |
13 | Partially correct | 0 ms | 588 KB | Output is partially correct |
14 | Partially correct | 1 ms | 588 KB | Output is partially correct |
15 | Partially correct | 1 ms | 588 KB | Output is partially correct |
16 | Partially correct | 1 ms | 588 KB | Output is partially correct |
17 | Partially correct | 1 ms | 588 KB | Output is partially correct |
18 | Partially correct | 1 ms | 588 KB | Output is partially correct |
19 | Partially correct | 1 ms | 588 KB | Output is partially correct |
20 | Correct | 1 ms | 588 KB | Output is correct |
21 | Partially correct | 1 ms | 536 KB | Output is partially correct |
22 | Partially correct | 1 ms | 588 KB | Output is partially correct |
23 | Partially correct | 1 ms | 588 KB | Output is partially correct |
24 | Partially correct | 1 ms | 588 KB | Output is partially correct |
25 | Partially correct | 1 ms | 588 KB | Output is partially correct |
26 | Partially correct | 1 ms | 588 KB | Output is partially correct |
27 | Partially correct | 1 ms | 540 KB | Output is partially correct |
28 | Correct | 1 ms | 588 KB | Output is correct |
29 | Partially correct | 0 ms | 588 KB | Output is partially correct |
30 | Partially correct | 1 ms | 588 KB | Output is partially correct |
31 | Partially correct | 1 ms | 588 KB | Output is partially correct |
32 | Correct | 1 ms | 588 KB | Output is correct |
33 | Partially correct | 0 ms | 588 KB | Output is partially correct |
34 | Correct | 1 ms | 588 KB | Output is correct |
35 | Partially correct | 1 ms | 588 KB | Output is partially correct |
36 | Partially correct | 1 ms | 536 KB | Output is partially correct |
37 | Partially correct | 1 ms | 588 KB | Output is partially correct |
38 | Partially correct | 1 ms | 540 KB | Output is partially correct |
39 | Partially correct | 1 ms | 528 KB | Output is partially correct |
40 | Partially correct | 1 ms | 588 KB | Output is partially correct |
41 | Partially correct | 1 ms | 588 KB | Output is partially correct |
42 | Partially correct | 1 ms | 588 KB | Output is partially correct |
43 | Partially correct | 1 ms | 588 KB | Output is partially correct |
44 | Correct | 1 ms | 588 KB | Output is correct |
45 | Partially correct | 1 ms | 588 KB | Output is partially correct |
46 | Partially correct | 1 ms | 588 KB | Output is partially correct |
47 | Partially correct | 1 ms | 540 KB | Output is partially correct |
48 | Partially correct | 1 ms | 588 KB | Output is partially correct |
49 | Partially correct | 1 ms | 588 KB | Output is partially correct |
50 | Partially correct | 1 ms | 588 KB | Output is partially correct |
51 | Partially correct | 1 ms | 540 KB | Output is partially correct |
52 | Partially correct | 1 ms | 588 KB | Output is partially correct |
53 | Partially correct | 1 ms | 588 KB | Output is partially correct |
54 | Partially correct | 1 ms | 588 KB | Output is partially correct |
55 | Partially correct | 1 ms | 588 KB | Output is partially correct |
56 | Correct | 1 ms | 556 KB | Output is correct |
57 | Partially correct | 1 ms | 588 KB | Output is partially correct |
58 | Correct | 1 ms | 588 KB | Output is correct |
59 | Correct | 0 ms | 204 KB | Output is correct |
60 | Runtime error | 1 ms | 460 KB | Execution killed with signal 11 |
61 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 0 ms | 204 KB | Output is partially correct |
2 | Partially correct | 1 ms | 588 KB | Output is partially correct |
3 | Partially correct | 1 ms | 588 KB | Output is partially correct |
4 | Partially correct | 1 ms | 588 KB | Output is partially correct |
5 | Partially correct | 1 ms | 588 KB | Output is partially correct |
6 | Partially correct | 1 ms | 588 KB | Output is partially correct |
7 | Correct | 1 ms | 588 KB | Output is correct |
8 | Partially correct | 1 ms | 588 KB | Output is partially correct |
9 | Partially correct | 1 ms | 588 KB | Output is partially correct |
10 | Correct | 1 ms | 588 KB | Output is correct |
11 | Partially correct | 1 ms | 588 KB | Output is partially correct |
12 | Partially correct | 1 ms | 544 KB | Output is partially correct |
13 | Partially correct | 0 ms | 588 KB | Output is partially correct |
14 | Partially correct | 1 ms | 588 KB | Output is partially correct |
15 | Partially correct | 1 ms | 588 KB | Output is partially correct |
16 | Partially correct | 1 ms | 588 KB | Output is partially correct |
17 | Partially correct | 1 ms | 588 KB | Output is partially correct |
18 | Partially correct | 1 ms | 588 KB | Output is partially correct |
19 | Partially correct | 1 ms | 588 KB | Output is partially correct |
20 | Correct | 1 ms | 588 KB | Output is correct |
21 | Partially correct | 1 ms | 536 KB | Output is partially correct |
22 | Partially correct | 1 ms | 588 KB | Output is partially correct |
23 | Partially correct | 1 ms | 588 KB | Output is partially correct |
24 | Partially correct | 1 ms | 588 KB | Output is partially correct |
25 | Partially correct | 1 ms | 588 KB | Output is partially correct |
26 | Partially correct | 1 ms | 588 KB | Output is partially correct |
27 | Partially correct | 1 ms | 540 KB | Output is partially correct |
28 | Correct | 1 ms | 588 KB | Output is correct |
29 | Partially correct | 0 ms | 588 KB | Output is partially correct |
30 | Partially correct | 1 ms | 588 KB | Output is partially correct |
31 | Partially correct | 1 ms | 588 KB | Output is partially correct |
32 | Correct | 1 ms | 588 KB | Output is correct |
33 | Partially correct | 0 ms | 588 KB | Output is partially correct |
34 | Correct | 1 ms | 588 KB | Output is correct |
35 | Partially correct | 1 ms | 588 KB | Output is partially correct |
36 | Partially correct | 1 ms | 536 KB | Output is partially correct |
37 | Partially correct | 1 ms | 588 KB | Output is partially correct |
38 | Partially correct | 1 ms | 540 KB | Output is partially correct |
39 | Partially correct | 1 ms | 528 KB | Output is partially correct |
40 | Partially correct | 1 ms | 588 KB | Output is partially correct |
41 | Partially correct | 1 ms | 588 KB | Output is partially correct |
42 | Partially correct | 1 ms | 588 KB | Output is partially correct |
43 | Partially correct | 1 ms | 588 KB | Output is partially correct |
44 | Correct | 1 ms | 588 KB | Output is correct |
45 | Partially correct | 1 ms | 588 KB | Output is partially correct |
46 | Partially correct | 1 ms | 588 KB | Output is partially correct |
47 | Partially correct | 1 ms | 540 KB | Output is partially correct |
48 | Partially correct | 1 ms | 588 KB | Output is partially correct |
49 | Partially correct | 1 ms | 588 KB | Output is partially correct |
50 | Partially correct | 1 ms | 588 KB | Output is partially correct |
51 | Partially correct | 1 ms | 540 KB | Output is partially correct |
52 | Partially correct | 1 ms | 588 KB | Output is partially correct |
53 | Partially correct | 1 ms | 588 KB | Output is partially correct |
54 | Partially correct | 1 ms | 588 KB | Output is partially correct |
55 | Partially correct | 1 ms | 588 KB | Output is partially correct |
56 | Correct | 1 ms | 556 KB | Output is correct |
57 | Partially correct | 1 ms | 588 KB | Output is partially correct |
58 | Correct | 1 ms | 588 KB | Output is correct |
59 | Correct | 0 ms | 204 KB | Output is correct |
60 | Runtime error | 1 ms | 460 KB | Execution killed with signal 11 |
61 | Halted | 0 ms | 0 KB | - |