# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
124491 | 2019-07-03T12:12:49 Z | DJ035 | None (KOI17_cat) | C++14 | 571 ms | 70064 KB |
#include <bits/stdc++.h> using namespace std; #define MAXN 300005 #define pb push_back typedef long long lld; int N, M, C; int dep[MAXN]; int U[MAXN], D[MAXN], F[MAXN]; vector <int> con[MAXN], child[MAXN]; void dfs(int n, int from) { for (int t: con[n]) if (t != from){ if (!dep[t]){ child[n].pb(t); dep[t] = dep[n]+1; int tmp = U[n]; dfs(t, n); F[t] = U[n]-tmp; U[n] += U[t]; D[n] += D[t]; }else if (dep[t] < dep[n]){ D[n]++; U[t]++; } } } int main() { scanf("%d%d", &N, &M); for (int i=1;i<=M;i++){ int a, b; scanf("%d%d", &a, &b); con[a].pb(b); con[b].pb(a); } dep[1] = 1; dfs(1, 0); lld ans = 0; for (int i=1;i<=N;i++){ bool skip = 0; for (int t: child[i]) if (D[t]-F[t] > 1 || U[t]) skip = 1; if (skip || M-(N-1)-D[i] != 0) continue; ans += i; } printf("%lld\n", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 14456 KB | Output is correct |
2 | Correct | 15 ms | 14456 KB | Output is correct |
3 | Correct | 15 ms | 14452 KB | Output is correct |
4 | Correct | 15 ms | 14584 KB | Output is correct |
5 | Correct | 17 ms | 14968 KB | Output is correct |
6 | Correct | 39 ms | 14840 KB | Output is correct |
7 | Correct | 18 ms | 15224 KB | Output is correct |
8 | Correct | 18 ms | 14840 KB | Output is correct |
9 | Correct | 17 ms | 15352 KB | Output is correct |
10 | Correct | 21 ms | 15096 KB | Output is correct |
11 | Correct | 18 ms | 15352 KB | Output is correct |
12 | Correct | 17 ms | 15224 KB | Output is correct |
13 | Correct | 17 ms | 14968 KB | Output is correct |
14 | Correct | 17 ms | 14968 KB | Output is correct |
15 | Correct | 18 ms | 14456 KB | Output is correct |
16 | Correct | 18 ms | 14456 KB | Output is correct |
17 | Correct | 15 ms | 14456 KB | Output is correct |
18 | Correct | 15 ms | 14456 KB | Output is correct |
19 | Correct | 18 ms | 14456 KB | Output is correct |
20 | Correct | 19 ms | 15168 KB | Output is correct |
21 | Correct | 18 ms | 15324 KB | Output is correct |
22 | Correct | 22 ms | 15224 KB | Output is correct |
23 | Correct | 19 ms | 14712 KB | Output is correct |
24 | Correct | 20 ms | 14972 KB | Output is correct |
25 | Correct | 15 ms | 14456 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 392 ms | 37564 KB | Output is correct |
2 | Correct | 358 ms | 37624 KB | Output is correct |
3 | Correct | 347 ms | 37620 KB | Output is correct |
4 | Correct | 376 ms | 37600 KB | Output is correct |
5 | Correct | 384 ms | 37556 KB | Output is correct |
6 | Correct | 386 ms | 37644 KB | Output is correct |
7 | Correct | 382 ms | 37652 KB | Output is correct |
8 | Correct | 358 ms | 37628 KB | Output is correct |
9 | Correct | 371 ms | 37564 KB | Output is correct |
10 | Correct | 360 ms | 37700 KB | Output is correct |
11 | Correct | 374 ms | 38284 KB | Output is correct |
12 | Correct | 359 ms | 38268 KB | Output is correct |
13 | Correct | 384 ms | 38320 KB | Output is correct |
14 | Correct | 357 ms | 38264 KB | Output is correct |
15 | Correct | 377 ms | 38304 KB | Output is correct |
16 | Correct | 378 ms | 44036 KB | Output is correct |
17 | Correct | 383 ms | 45436 KB | Output is correct |
18 | Correct | 376 ms | 42952 KB | Output is correct |
19 | Correct | 403 ms | 44152 KB | Output is correct |
20 | Correct | 370 ms | 42964 KB | Output is correct |
21 | Correct | 366 ms | 40696 KB | Output is correct |
22 | Correct | 374 ms | 52128 KB | Output is correct |
23 | Correct | 474 ms | 57100 KB | Output is correct |
24 | Correct | 380 ms | 40952 KB | Output is correct |
25 | Correct | 365 ms | 54812 KB | Output is correct |
26 | Correct | 194 ms | 69880 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 189 ms | 69936 KB | Output is correct |
2 | Correct | 189 ms | 69904 KB | Output is correct |
3 | Correct | 189 ms | 69960 KB | Output is correct |
4 | Correct | 185 ms | 69956 KB | Output is correct |
5 | Correct | 186 ms | 69976 KB | Output is correct |
6 | Correct | 181 ms | 69948 KB | Output is correct |
7 | Correct | 182 ms | 69892 KB | Output is correct |
8 | Correct | 181 ms | 70064 KB | Output is correct |
9 | Correct | 181 ms | 69992 KB | Output is correct |
10 | Correct | 201 ms | 61476 KB | Output is correct |
11 | Correct | 204 ms | 61556 KB | Output is correct |
12 | Correct | 197 ms | 61520 KB | Output is correct |
13 | Correct | 203 ms | 61656 KB | Output is correct |
14 | Correct | 200 ms | 61560 KB | Output is correct |
15 | Correct | 202 ms | 52976 KB | Output is correct |
16 | Correct | 241 ms | 53060 KB | Output is correct |
17 | Correct | 208 ms | 53088 KB | Output is correct |
18 | Correct | 209 ms | 52952 KB | Output is correct |
19 | Correct | 227 ms | 53132 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 14456 KB | Output is correct |
2 | Correct | 15 ms | 14456 KB | Output is correct |
3 | Correct | 15 ms | 14452 KB | Output is correct |
4 | Correct | 15 ms | 14584 KB | Output is correct |
5 | Correct | 17 ms | 14968 KB | Output is correct |
6 | Correct | 39 ms | 14840 KB | Output is correct |
7 | Correct | 18 ms | 15224 KB | Output is correct |
8 | Correct | 18 ms | 14840 KB | Output is correct |
9 | Correct | 17 ms | 15352 KB | Output is correct |
10 | Correct | 21 ms | 15096 KB | Output is correct |
11 | Correct | 18 ms | 15352 KB | Output is correct |
12 | Correct | 17 ms | 15224 KB | Output is correct |
13 | Correct | 17 ms | 14968 KB | Output is correct |
14 | Correct | 17 ms | 14968 KB | Output is correct |
15 | Correct | 18 ms | 14456 KB | Output is correct |
16 | Correct | 18 ms | 14456 KB | Output is correct |
17 | Correct | 15 ms | 14456 KB | Output is correct |
18 | Correct | 15 ms | 14456 KB | Output is correct |
19 | Correct | 18 ms | 14456 KB | Output is correct |
20 | Correct | 19 ms | 15168 KB | Output is correct |
21 | Correct | 18 ms | 15324 KB | Output is correct |
22 | Correct | 22 ms | 15224 KB | Output is correct |
23 | Correct | 19 ms | 14712 KB | Output is correct |
24 | Correct | 20 ms | 14972 KB | Output is correct |
25 | Correct | 15 ms | 14456 KB | Output is correct |
26 | Correct | 392 ms | 37564 KB | Output is correct |
27 | Correct | 358 ms | 37624 KB | Output is correct |
28 | Correct | 347 ms | 37620 KB | Output is correct |
29 | Correct | 376 ms | 37600 KB | Output is correct |
30 | Correct | 384 ms | 37556 KB | Output is correct |
31 | Correct | 386 ms | 37644 KB | Output is correct |
32 | Correct | 382 ms | 37652 KB | Output is correct |
33 | Correct | 358 ms | 37628 KB | Output is correct |
34 | Correct | 371 ms | 37564 KB | Output is correct |
35 | Correct | 360 ms | 37700 KB | Output is correct |
36 | Correct | 374 ms | 38284 KB | Output is correct |
37 | Correct | 359 ms | 38268 KB | Output is correct |
38 | Correct | 384 ms | 38320 KB | Output is correct |
39 | Correct | 357 ms | 38264 KB | Output is correct |
40 | Correct | 377 ms | 38304 KB | Output is correct |
41 | Correct | 378 ms | 44036 KB | Output is correct |
42 | Correct | 383 ms | 45436 KB | Output is correct |
43 | Correct | 376 ms | 42952 KB | Output is correct |
44 | Correct | 403 ms | 44152 KB | Output is correct |
45 | Correct | 370 ms | 42964 KB | Output is correct |
46 | Correct | 366 ms | 40696 KB | Output is correct |
47 | Correct | 374 ms | 52128 KB | Output is correct |
48 | Correct | 474 ms | 57100 KB | Output is correct |
49 | Correct | 380 ms | 40952 KB | Output is correct |
50 | Correct | 365 ms | 54812 KB | Output is correct |
51 | Correct | 194 ms | 69880 KB | Output is correct |
52 | Correct | 189 ms | 69936 KB | Output is correct |
53 | Correct | 189 ms | 69904 KB | Output is correct |
54 | Correct | 189 ms | 69960 KB | Output is correct |
55 | Correct | 185 ms | 69956 KB | Output is correct |
56 | Correct | 186 ms | 69976 KB | Output is correct |
57 | Correct | 181 ms | 69948 KB | Output is correct |
58 | Correct | 182 ms | 69892 KB | Output is correct |
59 | Correct | 181 ms | 70064 KB | Output is correct |
60 | Correct | 181 ms | 69992 KB | Output is correct |
61 | Correct | 201 ms | 61476 KB | Output is correct |
62 | Correct | 204 ms | 61556 KB | Output is correct |
63 | Correct | 197 ms | 61520 KB | Output is correct |
64 | Correct | 203 ms | 61656 KB | Output is correct |
65 | Correct | 200 ms | 61560 KB | Output is correct |
66 | Correct | 202 ms | 52976 KB | Output is correct |
67 | Correct | 241 ms | 53060 KB | Output is correct |
68 | Correct | 208 ms | 53088 KB | Output is correct |
69 | Correct | 209 ms | 52952 KB | Output is correct |
70 | Correct | 227 ms | 53132 KB | Output is correct |
71 | Correct | 466 ms | 67996 KB | Output is correct |
72 | Correct | 477 ms | 65872 KB | Output is correct |
73 | Correct | 467 ms | 64876 KB | Output is correct |
74 | Correct | 516 ms | 67120 KB | Output is correct |
75 | Correct | 443 ms | 63404 KB | Output is correct |
76 | Correct | 426 ms | 62872 KB | Output is correct |
77 | Correct | 445 ms | 57224 KB | Output is correct |
78 | Correct | 442 ms | 56628 KB | Output is correct |
79 | Correct | 444 ms | 67656 KB | Output is correct |
80 | Correct | 436 ms | 62668 KB | Output is correct |
81 | Correct | 430 ms | 58912 KB | Output is correct |
82 | Correct | 571 ms | 67620 KB | Output is correct |
83 | Correct | 455 ms | 67708 KB | Output is correct |
84 | Correct | 485 ms | 65932 KB | Output is correct |
85 | Correct | 429 ms | 66960 KB | Output is correct |
86 | Correct | 341 ms | 56304 KB | Output is correct |
87 | Correct | 323 ms | 55496 KB | Output is correct |
88 | Correct | 204 ms | 34136 KB | Output is correct |
89 | Correct | 216 ms | 34572 KB | Output is correct |
90 | Correct | 244 ms | 34484 KB | Output is correct |