Submission #283248

# Submission time Handle Problem Language Result Execution time Memory
283248 2020-08-25T12:20:33 Z jjaewon None (KOI17_cat) C++14
100 / 100
441 ms 70068 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
const int inf=0x3f3f3f3f;

int N,M,dep[300010],fu[300010],hf[300010],up[300010];
vector<int> edge[300010],ch[300010];

void dfs(int now,int prv){
	for(auto i:edge[now]) if(i!=prv){
		if(!dep[i]){
			dep[i]=dep[now]+1;
			ch[now].push_back(i);
			int t=fu[now];
			dfs(i,now);
			up[i]=fu[now]-t;
			fu[now]+=fu[i];
			hf[now]+=hf[i];
		}
		else if(dep[now]>dep[i]) fu[i]++, hf[now]++;
	}
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>N>>M;
    for(int i=0;i<M;i++){
    	int u,v; cin>>u>>v;
    	edge[u].push_back(v);
    	edge[v].push_back(u);
    }
    dep[1]=1; dfs(1,1);
    ll ans=0;
    for(int i=1;i<=N;i++){
    	bool flag=(M-N+1-hf[i]==0);
    	for(auto j:ch[i]) flag&=(hf[j]-up[j]<2&&fu[j]<1);
    	if(flag) ans+=i;
    }
    cout<<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 14464 KB Output is correct
2 Correct 9 ms 14592 KB Output is correct
3 Correct 9 ms 14464 KB Output is correct
4 Correct 9 ms 14464 KB Output is correct
5 Correct 12 ms 14976 KB Output is correct
6 Correct 12 ms 14848 KB Output is correct
7 Correct 12 ms 15232 KB Output is correct
8 Correct 12 ms 14848 KB Output is correct
9 Correct 13 ms 15360 KB Output is correct
10 Correct 13 ms 15104 KB Output is correct
11 Correct 12 ms 15360 KB Output is correct
12 Correct 13 ms 15180 KB Output is correct
13 Correct 11 ms 14976 KB Output is correct
14 Correct 12 ms 14976 KB Output is correct
15 Correct 10 ms 14464 KB Output is correct
16 Correct 9 ms 14464 KB Output is correct
17 Correct 10 ms 14464 KB Output is correct
18 Correct 9 ms 14464 KB Output is correct
19 Correct 9 ms 14464 KB Output is correct
20 Correct 12 ms 15232 KB Output is correct
21 Correct 13 ms 15232 KB Output is correct
22 Correct 12 ms 15232 KB Output is correct
23 Correct 11 ms 14848 KB Output is correct
24 Correct 11 ms 14848 KB Output is correct
25 Correct 11 ms 14464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 345 ms 37624 KB Output is correct
2 Correct 340 ms 37752 KB Output is correct
3 Correct 343 ms 37624 KB Output is correct
4 Correct 328 ms 37880 KB Output is correct
5 Correct 327 ms 37624 KB Output is correct
6 Correct 323 ms 37624 KB Output is correct
7 Correct 326 ms 37756 KB Output is correct
8 Correct 327 ms 37624 KB Output is correct
9 Correct 321 ms 37624 KB Output is correct
10 Correct 326 ms 37880 KB Output is correct
11 Correct 320 ms 38392 KB Output is correct
12 Correct 322 ms 38392 KB Output is correct
13 Correct 322 ms 38244 KB Output is correct
14 Correct 331 ms 38296 KB Output is correct
15 Correct 321 ms 38360 KB Output is correct
16 Correct 328 ms 44216 KB Output is correct
17 Correct 326 ms 45432 KB Output is correct
18 Correct 336 ms 43000 KB Output is correct
19 Correct 342 ms 44152 KB Output is correct
20 Correct 344 ms 43000 KB Output is correct
21 Correct 373 ms 40568 KB Output is correct
22 Correct 343 ms 52216 KB Output is correct
23 Correct 351 ms 57116 KB Output is correct
24 Correct 340 ms 40952 KB Output is correct
25 Correct 330 ms 54752 KB Output is correct
26 Correct 158 ms 69936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 163 ms 70008 KB Output is correct
2 Correct 161 ms 70008 KB Output is correct
3 Correct 158 ms 70008 KB Output is correct
4 Correct 189 ms 69932 KB Output is correct
5 Correct 161 ms 70068 KB Output is correct
6 Correct 155 ms 69936 KB Output is correct
7 Correct 180 ms 69980 KB Output is correct
8 Correct 154 ms 69960 KB Output is correct
9 Correct 157 ms 69944 KB Output is correct
10 Correct 164 ms 61576 KB Output is correct
11 Correct 169 ms 61532 KB Output is correct
12 Correct 165 ms 61516 KB Output is correct
13 Correct 197 ms 61560 KB Output is correct
14 Correct 162 ms 61608 KB Output is correct
15 Correct 174 ms 53056 KB Output is correct
16 Correct 175 ms 52976 KB Output is correct
17 Correct 170 ms 53100 KB Output is correct
18 Correct 170 ms 52972 KB Output is correct
19 Correct 169 ms 53104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 14464 KB Output is correct
2 Correct 9 ms 14592 KB Output is correct
3 Correct 9 ms 14464 KB Output is correct
4 Correct 9 ms 14464 KB Output is correct
5 Correct 12 ms 14976 KB Output is correct
6 Correct 12 ms 14848 KB Output is correct
7 Correct 12 ms 15232 KB Output is correct
8 Correct 12 ms 14848 KB Output is correct
9 Correct 13 ms 15360 KB Output is correct
10 Correct 13 ms 15104 KB Output is correct
11 Correct 12 ms 15360 KB Output is correct
12 Correct 13 ms 15180 KB Output is correct
13 Correct 11 ms 14976 KB Output is correct
14 Correct 12 ms 14976 KB Output is correct
15 Correct 10 ms 14464 KB Output is correct
16 Correct 9 ms 14464 KB Output is correct
17 Correct 10 ms 14464 KB Output is correct
18 Correct 9 ms 14464 KB Output is correct
19 Correct 9 ms 14464 KB Output is correct
20 Correct 12 ms 15232 KB Output is correct
21 Correct 13 ms 15232 KB Output is correct
22 Correct 12 ms 15232 KB Output is correct
23 Correct 11 ms 14848 KB Output is correct
24 Correct 11 ms 14848 KB Output is correct
25 Correct 11 ms 14464 KB Output is correct
26 Correct 345 ms 37624 KB Output is correct
27 Correct 340 ms 37752 KB Output is correct
28 Correct 343 ms 37624 KB Output is correct
29 Correct 328 ms 37880 KB Output is correct
30 Correct 327 ms 37624 KB Output is correct
31 Correct 323 ms 37624 KB Output is correct
32 Correct 326 ms 37756 KB Output is correct
33 Correct 327 ms 37624 KB Output is correct
34 Correct 321 ms 37624 KB Output is correct
35 Correct 326 ms 37880 KB Output is correct
36 Correct 320 ms 38392 KB Output is correct
37 Correct 322 ms 38392 KB Output is correct
38 Correct 322 ms 38244 KB Output is correct
39 Correct 331 ms 38296 KB Output is correct
40 Correct 321 ms 38360 KB Output is correct
41 Correct 328 ms 44216 KB Output is correct
42 Correct 326 ms 45432 KB Output is correct
43 Correct 336 ms 43000 KB Output is correct
44 Correct 342 ms 44152 KB Output is correct
45 Correct 344 ms 43000 KB Output is correct
46 Correct 373 ms 40568 KB Output is correct
47 Correct 343 ms 52216 KB Output is correct
48 Correct 351 ms 57116 KB Output is correct
49 Correct 340 ms 40952 KB Output is correct
50 Correct 330 ms 54752 KB Output is correct
51 Correct 158 ms 69936 KB Output is correct
52 Correct 163 ms 70008 KB Output is correct
53 Correct 161 ms 70008 KB Output is correct
54 Correct 158 ms 70008 KB Output is correct
55 Correct 189 ms 69932 KB Output is correct
56 Correct 161 ms 70068 KB Output is correct
57 Correct 155 ms 69936 KB Output is correct
58 Correct 180 ms 69980 KB Output is correct
59 Correct 154 ms 69960 KB Output is correct
60 Correct 157 ms 69944 KB Output is correct
61 Correct 164 ms 61576 KB Output is correct
62 Correct 169 ms 61532 KB Output is correct
63 Correct 165 ms 61516 KB Output is correct
64 Correct 197 ms 61560 KB Output is correct
65 Correct 162 ms 61608 KB Output is correct
66 Correct 174 ms 53056 KB Output is correct
67 Correct 175 ms 52976 KB Output is correct
68 Correct 170 ms 53100 KB Output is correct
69 Correct 170 ms 52972 KB Output is correct
70 Correct 169 ms 53104 KB Output is correct
71 Correct 430 ms 68164 KB Output is correct
72 Correct 420 ms 65784 KB Output is correct
73 Correct 427 ms 64888 KB Output is correct
74 Correct 441 ms 67448 KB Output is correct
75 Correct 419 ms 63448 KB Output is correct
76 Correct 409 ms 63096 KB Output is correct
77 Correct 401 ms 57188 KB Output is correct
78 Correct 400 ms 56764 KB Output is correct
79 Correct 410 ms 67704 KB Output is correct
80 Correct 410 ms 62712 KB Output is correct
81 Correct 406 ms 59000 KB Output is correct
82 Correct 412 ms 67448 KB Output is correct
83 Correct 409 ms 67704 KB Output is correct
84 Correct 405 ms 65912 KB Output is correct
85 Correct 407 ms 67032 KB Output is correct
86 Correct 274 ms 56304 KB Output is correct
87 Correct 292 ms 55672 KB Output is correct
88 Correct 178 ms 34276 KB Output is correct
89 Correct 176 ms 34660 KB Output is correct
90 Correct 183 ms 34532 KB Output is correct