# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
469948 |
2021-09-02T11:44:57 Z |
1bin |
None (KOI17_cat) |
C++14 |
|
371 ms |
60520 KB |
#include <bits/stdc++.h>
#include <cassert>
using namespace std;
#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 3e5 + 5;
ll n, m, a, b, dfsn[NMAX], cnt[NMAX], x[NMAX], y[NMAX], t, ans, sum;
vector<int> adj[NMAX];
void dfs(int now, int bef) {
dfsn[now] = ++t;
int f = 1;
for (int nx : adj[now]) {
if (nx == bef) continue;
if (!dfsn[nx]) {
ll c = cnt[now];
dfs(nx, now);
cnt[now] += cnt[nx];
if (cnt[now] - c > 1) f = 0;
x[now] += x[nx]; y[now] += y[nx];
}
else if (dfsn[nx] < dfsn[now]) x[now]++, cnt[now]++, cnt[nx]--;
else y[bef]++;
}
if (!y[now] && !(sum - x[now]) && f) ans += now;
return;
}
int main(void) {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m;
sum = m - (n - 1);
assert(sum > 0);
while (m--) {
cin >> a >> b;
adj[a].emplace_back(b);
adj[b].emplace_back(a);
}
dfs(1, 0);
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7372 KB |
Output is correct |
2 |
Correct |
4 ms |
7372 KB |
Output is correct |
3 |
Correct |
5 ms |
7372 KB |
Output is correct |
4 |
Correct |
5 ms |
7368 KB |
Output is correct |
5 |
Correct |
7 ms |
7884 KB |
Output is correct |
6 |
Correct |
6 ms |
7764 KB |
Output is correct |
7 |
Correct |
7 ms |
8012 KB |
Output is correct |
8 |
Correct |
7 ms |
7756 KB |
Output is correct |
9 |
Correct |
6 ms |
8268 KB |
Output is correct |
10 |
Correct |
6 ms |
8012 KB |
Output is correct |
11 |
Correct |
6 ms |
8140 KB |
Output is correct |
12 |
Correct |
6 ms |
8140 KB |
Output is correct |
13 |
Correct |
6 ms |
7884 KB |
Output is correct |
14 |
Correct |
7 ms |
7884 KB |
Output is correct |
15 |
Correct |
5 ms |
7372 KB |
Output is correct |
16 |
Correct |
4 ms |
7372 KB |
Output is correct |
17 |
Correct |
5 ms |
7372 KB |
Output is correct |
18 |
Correct |
5 ms |
7372 KB |
Output is correct |
19 |
Correct |
5 ms |
7372 KB |
Output is correct |
20 |
Correct |
8 ms |
8124 KB |
Output is correct |
21 |
Correct |
8 ms |
8140 KB |
Output is correct |
22 |
Correct |
7 ms |
8140 KB |
Output is correct |
23 |
Correct |
7 ms |
7628 KB |
Output is correct |
24 |
Correct |
6 ms |
7628 KB |
Output is correct |
25 |
Correct |
5 ms |
7372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
244 ms |
26780 KB |
Output is correct |
2 |
Correct |
263 ms |
26788 KB |
Output is correct |
3 |
Correct |
298 ms |
26780 KB |
Output is correct |
4 |
Correct |
255 ms |
26948 KB |
Output is correct |
5 |
Correct |
268 ms |
26784 KB |
Output is correct |
6 |
Correct |
282 ms |
26844 KB |
Output is correct |
7 |
Correct |
266 ms |
26752 KB |
Output is correct |
8 |
Correct |
264 ms |
26800 KB |
Output is correct |
9 |
Correct |
275 ms |
26920 KB |
Output is correct |
10 |
Correct |
270 ms |
26944 KB |
Output is correct |
11 |
Correct |
254 ms |
27552 KB |
Output is correct |
12 |
Correct |
268 ms |
27576 KB |
Output is correct |
13 |
Correct |
264 ms |
27408 KB |
Output is correct |
14 |
Correct |
273 ms |
27652 KB |
Output is correct |
15 |
Correct |
260 ms |
27640 KB |
Output is correct |
16 |
Correct |
237 ms |
33992 KB |
Output is correct |
17 |
Correct |
254 ms |
35392 KB |
Output is correct |
18 |
Correct |
247 ms |
32372 KB |
Output is correct |
19 |
Correct |
271 ms |
33952 KB |
Output is correct |
20 |
Correct |
243 ms |
32592 KB |
Output is correct |
21 |
Correct |
275 ms |
30176 KB |
Output is correct |
22 |
Correct |
254 ms |
42564 KB |
Output is correct |
23 |
Correct |
221 ms |
46616 KB |
Output is correct |
24 |
Correct |
245 ms |
30672 KB |
Output is correct |
25 |
Correct |
232 ms |
45100 KB |
Output is correct |
26 |
Correct |
130 ms |
59204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
130 ms |
59232 KB |
Output is correct |
2 |
Correct |
129 ms |
59272 KB |
Output is correct |
3 |
Correct |
125 ms |
59248 KB |
Output is correct |
4 |
Correct |
123 ms |
59220 KB |
Output is correct |
5 |
Correct |
127 ms |
59204 KB |
Output is correct |
6 |
Correct |
127 ms |
59248 KB |
Output is correct |
7 |
Correct |
127 ms |
59424 KB |
Output is correct |
8 |
Correct |
140 ms |
59220 KB |
Output is correct |
9 |
Correct |
132 ms |
59292 KB |
Output is correct |
10 |
Correct |
137 ms |
51040 KB |
Output is correct |
11 |
Correct |
138 ms |
51036 KB |
Output is correct |
12 |
Correct |
140 ms |
51052 KB |
Output is correct |
13 |
Correct |
135 ms |
51008 KB |
Output is correct |
14 |
Correct |
140 ms |
51012 KB |
Output is correct |
15 |
Correct |
144 ms |
42588 KB |
Output is correct |
16 |
Correct |
153 ms |
42532 KB |
Output is correct |
17 |
Correct |
147 ms |
42620 KB |
Output is correct |
18 |
Correct |
145 ms |
42636 KB |
Output is correct |
19 |
Correct |
140 ms |
42516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7372 KB |
Output is correct |
2 |
Correct |
4 ms |
7372 KB |
Output is correct |
3 |
Correct |
5 ms |
7372 KB |
Output is correct |
4 |
Correct |
5 ms |
7368 KB |
Output is correct |
5 |
Correct |
7 ms |
7884 KB |
Output is correct |
6 |
Correct |
6 ms |
7764 KB |
Output is correct |
7 |
Correct |
7 ms |
8012 KB |
Output is correct |
8 |
Correct |
7 ms |
7756 KB |
Output is correct |
9 |
Correct |
6 ms |
8268 KB |
Output is correct |
10 |
Correct |
6 ms |
8012 KB |
Output is correct |
11 |
Correct |
6 ms |
8140 KB |
Output is correct |
12 |
Correct |
6 ms |
8140 KB |
Output is correct |
13 |
Correct |
6 ms |
7884 KB |
Output is correct |
14 |
Correct |
7 ms |
7884 KB |
Output is correct |
15 |
Correct |
5 ms |
7372 KB |
Output is correct |
16 |
Correct |
4 ms |
7372 KB |
Output is correct |
17 |
Correct |
5 ms |
7372 KB |
Output is correct |
18 |
Correct |
5 ms |
7372 KB |
Output is correct |
19 |
Correct |
5 ms |
7372 KB |
Output is correct |
20 |
Correct |
8 ms |
8124 KB |
Output is correct |
21 |
Correct |
8 ms |
8140 KB |
Output is correct |
22 |
Correct |
7 ms |
8140 KB |
Output is correct |
23 |
Correct |
7 ms |
7628 KB |
Output is correct |
24 |
Correct |
6 ms |
7628 KB |
Output is correct |
25 |
Correct |
5 ms |
7372 KB |
Output is correct |
26 |
Correct |
244 ms |
26780 KB |
Output is correct |
27 |
Correct |
263 ms |
26788 KB |
Output is correct |
28 |
Correct |
298 ms |
26780 KB |
Output is correct |
29 |
Correct |
255 ms |
26948 KB |
Output is correct |
30 |
Correct |
268 ms |
26784 KB |
Output is correct |
31 |
Correct |
282 ms |
26844 KB |
Output is correct |
32 |
Correct |
266 ms |
26752 KB |
Output is correct |
33 |
Correct |
264 ms |
26800 KB |
Output is correct |
34 |
Correct |
275 ms |
26920 KB |
Output is correct |
35 |
Correct |
270 ms |
26944 KB |
Output is correct |
36 |
Correct |
254 ms |
27552 KB |
Output is correct |
37 |
Correct |
268 ms |
27576 KB |
Output is correct |
38 |
Correct |
264 ms |
27408 KB |
Output is correct |
39 |
Correct |
273 ms |
27652 KB |
Output is correct |
40 |
Correct |
260 ms |
27640 KB |
Output is correct |
41 |
Correct |
237 ms |
33992 KB |
Output is correct |
42 |
Correct |
254 ms |
35392 KB |
Output is correct |
43 |
Correct |
247 ms |
32372 KB |
Output is correct |
44 |
Correct |
271 ms |
33952 KB |
Output is correct |
45 |
Correct |
243 ms |
32592 KB |
Output is correct |
46 |
Correct |
275 ms |
30176 KB |
Output is correct |
47 |
Correct |
254 ms |
42564 KB |
Output is correct |
48 |
Correct |
221 ms |
46616 KB |
Output is correct |
49 |
Correct |
245 ms |
30672 KB |
Output is correct |
50 |
Correct |
232 ms |
45100 KB |
Output is correct |
51 |
Correct |
130 ms |
59204 KB |
Output is correct |
52 |
Correct |
130 ms |
59232 KB |
Output is correct |
53 |
Correct |
129 ms |
59272 KB |
Output is correct |
54 |
Correct |
125 ms |
59248 KB |
Output is correct |
55 |
Correct |
123 ms |
59220 KB |
Output is correct |
56 |
Correct |
127 ms |
59204 KB |
Output is correct |
57 |
Correct |
127 ms |
59248 KB |
Output is correct |
58 |
Correct |
127 ms |
59424 KB |
Output is correct |
59 |
Correct |
140 ms |
59220 KB |
Output is correct |
60 |
Correct |
132 ms |
59292 KB |
Output is correct |
61 |
Correct |
137 ms |
51040 KB |
Output is correct |
62 |
Correct |
138 ms |
51036 KB |
Output is correct |
63 |
Correct |
140 ms |
51052 KB |
Output is correct |
64 |
Correct |
135 ms |
51008 KB |
Output is correct |
65 |
Correct |
140 ms |
51012 KB |
Output is correct |
66 |
Correct |
144 ms |
42588 KB |
Output is correct |
67 |
Correct |
153 ms |
42532 KB |
Output is correct |
68 |
Correct |
147 ms |
42620 KB |
Output is correct |
69 |
Correct |
145 ms |
42636 KB |
Output is correct |
70 |
Correct |
140 ms |
42516 KB |
Output is correct |
71 |
Correct |
331 ms |
60520 KB |
Output is correct |
72 |
Correct |
302 ms |
57904 KB |
Output is correct |
73 |
Correct |
330 ms |
56856 KB |
Output is correct |
74 |
Correct |
347 ms |
59628 KB |
Output is correct |
75 |
Correct |
330 ms |
55068 KB |
Output is correct |
76 |
Correct |
318 ms |
54764 KB |
Output is correct |
77 |
Correct |
310 ms |
47892 KB |
Output is correct |
78 |
Correct |
315 ms |
47484 KB |
Output is correct |
79 |
Correct |
296 ms |
60232 KB |
Output is correct |
80 |
Correct |
339 ms |
54480 KB |
Output is correct |
81 |
Correct |
280 ms |
49944 KB |
Output is correct |
82 |
Correct |
371 ms |
59996 KB |
Output is correct |
83 |
Correct |
290 ms |
60128 KB |
Output is correct |
84 |
Correct |
298 ms |
58124 KB |
Output is correct |
85 |
Correct |
278 ms |
59416 KB |
Output is correct |
86 |
Correct |
214 ms |
49880 KB |
Output is correct |
87 |
Correct |
199 ms |
48888 KB |
Output is correct |
88 |
Correct |
147 ms |
23972 KB |
Output is correct |
89 |
Correct |
152 ms |
24336 KB |
Output is correct |
90 |
Correct |
156 ms |
24332 KB |
Output is correct |