# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
131542 |
2019-07-17T09:13:26 Z |
dndhk |
None (KOI17_cat) |
C++14 |
|
460 ms |
40056 KB |
#include <bits/stdc++.h>
#define pb push_back
#define all(v) ((v).begin(), (v).end())
#define sortv(v) sort(all(v))
#define sz(v) ((int)(v).size())
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define umax(a, b) (a)=max((a), (b))
#define umin(a, b) (a)=min((a), (b))
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define rep(i,n) FOR(i,1,n)
#define rep0(i,n) FOR(i,0,(int)(n)-1)
#define FI first
#define SE second
#define INF 2000000000
#define INFLL 1000000000000000000LL
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAX_N = 300000;
int N, M;
vector<int> gp[MAX_N+1];
int lv[MAX_N+1], p[MAX_N+1], C[MAX_N+1], up[MAX_N+1];
bool vst[MAX_N+1];
bool chk[MAX_N+1];
ll ans;
void dfs(int x){
vst[x] = chk[x] = true;
for(int i=0; i<gp[x].size(); i++){
if(gp[x][i]==p[x]) continue;
if(vst[gp[x][i]]){
if(lv[x]>lv[gp[x][i]]){C[x]++; up[gp[x][i]]++;}
continue;
}
lv[gp[x][i]] = lv[x]+1; p[gp[x][i]] = x;
dfs(gp[x][i]); C[x] += C[gp[x][i]];
if(C[gp[x][i]] - up[x] > 1) chk[x] = false;
if(up[x]>0) chk[p[x]] = false;
up[p[x]]+=up[x]; up[x] = 0;
}
if(chk[x] && C[x]==M) ans+=(ll)x;
}
int main(){
scanf("%d%d", &N, &M);
for(int i=0; i<M; i++){
int a, b; scanf("%d%d", &a, &b);
gp[a].pb(b); gp[b].pb(a);
}
M -= (N-1);
lv[1] = 1; dfs(1);
cout<<ans;
return 0;
}
Compilation message
cat.cpp: In function 'void dfs(int)':
cat.cpp:35:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<gp[x].size(); i++){
~^~~~~~~~~~~~~
cat.cpp: In function 'int main()':
cat.cpp:52:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &N, &M);
~~~~~^~~~~~~~~~~~~~~~
cat.cpp:54:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
int a, b; scanf("%d%d", &a, &b);
~~~~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
7416 KB |
Output is correct |
2 |
Correct |
8 ms |
7416 KB |
Output is correct |
3 |
Correct |
8 ms |
7416 KB |
Output is correct |
4 |
Correct |
8 ms |
7416 KB |
Output is correct |
5 |
Correct |
10 ms |
7800 KB |
Output is correct |
6 |
Correct |
10 ms |
7672 KB |
Output is correct |
7 |
Correct |
11 ms |
7800 KB |
Output is correct |
8 |
Correct |
10 ms |
7800 KB |
Output is correct |
9 |
Correct |
11 ms |
7928 KB |
Output is correct |
10 |
Correct |
10 ms |
7800 KB |
Output is correct |
11 |
Correct |
10 ms |
7928 KB |
Output is correct |
12 |
Correct |
11 ms |
7900 KB |
Output is correct |
13 |
Correct |
10 ms |
7800 KB |
Output is correct |
14 |
Correct |
13 ms |
7800 KB |
Output is correct |
15 |
Correct |
8 ms |
7416 KB |
Output is correct |
16 |
Correct |
8 ms |
7416 KB |
Output is correct |
17 |
Correct |
8 ms |
7416 KB |
Output is correct |
18 |
Correct |
8 ms |
7416 KB |
Output is correct |
19 |
Correct |
8 ms |
7544 KB |
Output is correct |
20 |
Correct |
11 ms |
7800 KB |
Output is correct |
21 |
Correct |
11 ms |
7860 KB |
Output is correct |
22 |
Correct |
11 ms |
7928 KB |
Output is correct |
23 |
Correct |
10 ms |
7672 KB |
Output is correct |
24 |
Correct |
10 ms |
7676 KB |
Output is correct |
25 |
Correct |
8 ms |
7416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
272 ms |
26284 KB |
Output is correct |
2 |
Correct |
282 ms |
26296 KB |
Output is correct |
3 |
Correct |
303 ms |
26404 KB |
Output is correct |
4 |
Correct |
289 ms |
26232 KB |
Output is correct |
5 |
Correct |
293 ms |
26232 KB |
Output is correct |
6 |
Correct |
293 ms |
26232 KB |
Output is correct |
7 |
Correct |
290 ms |
26488 KB |
Output is correct |
8 |
Correct |
307 ms |
26368 KB |
Output is correct |
9 |
Correct |
268 ms |
26360 KB |
Output is correct |
10 |
Correct |
287 ms |
26232 KB |
Output is correct |
11 |
Correct |
292 ms |
26616 KB |
Output is correct |
12 |
Correct |
316 ms |
26884 KB |
Output is correct |
13 |
Correct |
277 ms |
26616 KB |
Output is correct |
14 |
Correct |
278 ms |
26712 KB |
Output is correct |
15 |
Correct |
282 ms |
26760 KB |
Output is correct |
16 |
Correct |
283 ms |
29148 KB |
Output is correct |
17 |
Correct |
285 ms |
29944 KB |
Output is correct |
18 |
Correct |
314 ms |
28536 KB |
Output is correct |
19 |
Correct |
300 ms |
29456 KB |
Output is correct |
20 |
Correct |
279 ms |
28592 KB |
Output is correct |
21 |
Correct |
281 ms |
27896 KB |
Output is correct |
22 |
Correct |
291 ms |
33016 KB |
Output is correct |
23 |
Correct |
284 ms |
34684 KB |
Output is correct |
24 |
Correct |
277 ms |
27896 KB |
Output is correct |
25 |
Correct |
259 ms |
33912 KB |
Output is correct |
26 |
Correct |
139 ms |
40056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
142 ms |
40056 KB |
Output is correct |
2 |
Correct |
141 ms |
40008 KB |
Output is correct |
3 |
Correct |
147 ms |
40056 KB |
Output is correct |
4 |
Correct |
139 ms |
40044 KB |
Output is correct |
5 |
Correct |
139 ms |
39972 KB |
Output is correct |
6 |
Correct |
143 ms |
40024 KB |
Output is correct |
7 |
Correct |
139 ms |
39976 KB |
Output is correct |
8 |
Correct |
141 ms |
40056 KB |
Output is correct |
9 |
Correct |
140 ms |
40056 KB |
Output is correct |
10 |
Correct |
157 ms |
35484 KB |
Output is correct |
11 |
Correct |
172 ms |
35496 KB |
Output is correct |
12 |
Correct |
182 ms |
35584 KB |
Output is correct |
13 |
Correct |
160 ms |
35572 KB |
Output is correct |
14 |
Correct |
157 ms |
35548 KB |
Output is correct |
15 |
Correct |
162 ms |
30832 KB |
Output is correct |
16 |
Correct |
161 ms |
30828 KB |
Output is correct |
17 |
Correct |
169 ms |
30960 KB |
Output is correct |
18 |
Correct |
167 ms |
30808 KB |
Output is correct |
19 |
Correct |
168 ms |
30828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
7416 KB |
Output is correct |
2 |
Correct |
8 ms |
7416 KB |
Output is correct |
3 |
Correct |
8 ms |
7416 KB |
Output is correct |
4 |
Correct |
8 ms |
7416 KB |
Output is correct |
5 |
Correct |
10 ms |
7800 KB |
Output is correct |
6 |
Correct |
10 ms |
7672 KB |
Output is correct |
7 |
Correct |
11 ms |
7800 KB |
Output is correct |
8 |
Correct |
10 ms |
7800 KB |
Output is correct |
9 |
Correct |
11 ms |
7928 KB |
Output is correct |
10 |
Correct |
10 ms |
7800 KB |
Output is correct |
11 |
Correct |
10 ms |
7928 KB |
Output is correct |
12 |
Correct |
11 ms |
7900 KB |
Output is correct |
13 |
Correct |
10 ms |
7800 KB |
Output is correct |
14 |
Correct |
13 ms |
7800 KB |
Output is correct |
15 |
Correct |
8 ms |
7416 KB |
Output is correct |
16 |
Correct |
8 ms |
7416 KB |
Output is correct |
17 |
Correct |
8 ms |
7416 KB |
Output is correct |
18 |
Correct |
8 ms |
7416 KB |
Output is correct |
19 |
Correct |
8 ms |
7544 KB |
Output is correct |
20 |
Correct |
11 ms |
7800 KB |
Output is correct |
21 |
Correct |
11 ms |
7860 KB |
Output is correct |
22 |
Correct |
11 ms |
7928 KB |
Output is correct |
23 |
Correct |
10 ms |
7672 KB |
Output is correct |
24 |
Correct |
10 ms |
7676 KB |
Output is correct |
25 |
Correct |
8 ms |
7416 KB |
Output is correct |
26 |
Correct |
272 ms |
26284 KB |
Output is correct |
27 |
Correct |
282 ms |
26296 KB |
Output is correct |
28 |
Correct |
303 ms |
26404 KB |
Output is correct |
29 |
Correct |
289 ms |
26232 KB |
Output is correct |
30 |
Correct |
293 ms |
26232 KB |
Output is correct |
31 |
Correct |
293 ms |
26232 KB |
Output is correct |
32 |
Correct |
290 ms |
26488 KB |
Output is correct |
33 |
Correct |
307 ms |
26368 KB |
Output is correct |
34 |
Correct |
268 ms |
26360 KB |
Output is correct |
35 |
Correct |
287 ms |
26232 KB |
Output is correct |
36 |
Correct |
292 ms |
26616 KB |
Output is correct |
37 |
Correct |
316 ms |
26884 KB |
Output is correct |
38 |
Correct |
277 ms |
26616 KB |
Output is correct |
39 |
Correct |
278 ms |
26712 KB |
Output is correct |
40 |
Correct |
282 ms |
26760 KB |
Output is correct |
41 |
Correct |
283 ms |
29148 KB |
Output is correct |
42 |
Correct |
285 ms |
29944 KB |
Output is correct |
43 |
Correct |
314 ms |
28536 KB |
Output is correct |
44 |
Correct |
300 ms |
29456 KB |
Output is correct |
45 |
Correct |
279 ms |
28592 KB |
Output is correct |
46 |
Correct |
281 ms |
27896 KB |
Output is correct |
47 |
Correct |
291 ms |
33016 KB |
Output is correct |
48 |
Correct |
284 ms |
34684 KB |
Output is correct |
49 |
Correct |
277 ms |
27896 KB |
Output is correct |
50 |
Correct |
259 ms |
33912 KB |
Output is correct |
51 |
Correct |
139 ms |
40056 KB |
Output is correct |
52 |
Correct |
142 ms |
40056 KB |
Output is correct |
53 |
Correct |
141 ms |
40008 KB |
Output is correct |
54 |
Correct |
147 ms |
40056 KB |
Output is correct |
55 |
Correct |
139 ms |
40044 KB |
Output is correct |
56 |
Correct |
139 ms |
39972 KB |
Output is correct |
57 |
Correct |
143 ms |
40024 KB |
Output is correct |
58 |
Correct |
139 ms |
39976 KB |
Output is correct |
59 |
Correct |
141 ms |
40056 KB |
Output is correct |
60 |
Correct |
140 ms |
40056 KB |
Output is correct |
61 |
Correct |
157 ms |
35484 KB |
Output is correct |
62 |
Correct |
172 ms |
35496 KB |
Output is correct |
63 |
Correct |
182 ms |
35584 KB |
Output is correct |
64 |
Correct |
160 ms |
35572 KB |
Output is correct |
65 |
Correct |
157 ms |
35548 KB |
Output is correct |
66 |
Correct |
162 ms |
30832 KB |
Output is correct |
67 |
Correct |
161 ms |
30828 KB |
Output is correct |
68 |
Correct |
169 ms |
30960 KB |
Output is correct |
69 |
Correct |
167 ms |
30808 KB |
Output is correct |
70 |
Correct |
168 ms |
30828 KB |
Output is correct |
71 |
Correct |
342 ms |
39004 KB |
Output is correct |
72 |
Correct |
343 ms |
37908 KB |
Output is correct |
73 |
Correct |
359 ms |
37484 KB |
Output is correct |
74 |
Correct |
429 ms |
38860 KB |
Output is correct |
75 |
Correct |
382 ms |
36856 KB |
Output is correct |
76 |
Correct |
339 ms |
36472 KB |
Output is correct |
77 |
Correct |
378 ms |
33584 KB |
Output is correct |
78 |
Correct |
332 ms |
33388 KB |
Output is correct |
79 |
Correct |
336 ms |
39032 KB |
Output is correct |
80 |
Correct |
339 ms |
36396 KB |
Output is correct |
81 |
Correct |
340 ms |
34420 KB |
Output is correct |
82 |
Correct |
342 ms |
38876 KB |
Output is correct |
83 |
Correct |
460 ms |
38904 KB |
Output is correct |
84 |
Correct |
350 ms |
38036 KB |
Output is correct |
85 |
Correct |
345 ms |
38520 KB |
Output is correct |
86 |
Correct |
220 ms |
34212 KB |
Output is correct |
87 |
Correct |
215 ms |
33776 KB |
Output is correct |
88 |
Correct |
177 ms |
24584 KB |
Output is correct |
89 |
Correct |
198 ms |
25060 KB |
Output is correct |
90 |
Correct |
209 ms |
25012 KB |
Output is correct |