Submission #976581

# Submission time Handle Problem Language Result Execution time Memory
976581 2024-05-06T18:41:28 Z happy_node Meetings 2 (JOI21_meetings2) C++17
20 / 100
4000 ms 15340 KB
#include <bits/stdc++.h>
using namespace std;
 
const int MX=2e5+5;
int N;
vector<int> adj[MX];
 
int sz[MX], ans[MX];
 
void dfs(int v, int p, int head, int dep) {
	sz[v]=1;
	for(auto u:adj[v]) {
		if(u==p) continue;
		dfs(u,v,head,dep+1);
		sz[v]+=sz[u];
	}
}	
 
void dfs2(int v, int p, int head, int dep) {
	for(auto u:adj[v]) {
		if(u==p) continue;
		dfs2(u,v,head,dep+1);
	}
	int k=min(sz[v],N-sz[head]);
	ans[2*k]=max(ans[2*k],dep+1);
}	
 
 
int main() {
	cin.tie(0); ios_base::sync_with_stdio(0);
 
	cin>>N;
	for(int i=1;i<N;i++) {
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
 
	for(int r=1;r<=N;r++) {
		for(auto u:adj[r]) {
			dfs(u,r,u,1);
			dfs2(u,r,u,1);
		}
	}

	ans[N+1]=1;
	for(int i=N;i>=1;i--) ans[i]=max(ans[i],ans[i+1]);
 
	for(int i=1;i<=N;i++) {
		if(i&1) cout<<1<<'\n';
		else cout<<ans[i]<<'\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6504 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 2 ms 6320 KB Output is correct
10 Correct 3 ms 6492 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 3 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 3 ms 6540 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6504 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 2 ms 6320 KB Output is correct
10 Correct 3 ms 6492 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 3 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 3 ms 6540 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 398 ms 6960 KB Output is correct
23 Correct 400 ms 6696 KB Output is correct
24 Correct 367 ms 6708 KB Output is correct
25 Correct 365 ms 6736 KB Output is correct
26 Correct 372 ms 6744 KB Output is correct
27 Correct 376 ms 6704 KB Output is correct
28 Correct 390 ms 6700 KB Output is correct
29 Correct 381 ms 6488 KB Output is correct
30 Correct 381 ms 6696 KB Output is correct
31 Correct 377 ms 6700 KB Output is correct
32 Correct 418 ms 6872 KB Output is correct
33 Correct 349 ms 7008 KB Output is correct
34 Correct 309 ms 6696 KB Output is correct
35 Correct 155 ms 6492 KB Output is correct
36 Correct 248 ms 6744 KB Output is correct
37 Correct 163 ms 6708 KB Output is correct
38 Correct 250 ms 6744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6504 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 2 ms 6320 KB Output is correct
10 Correct 3 ms 6492 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 3 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 3 ms 6540 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 398 ms 6960 KB Output is correct
23 Correct 400 ms 6696 KB Output is correct
24 Correct 367 ms 6708 KB Output is correct
25 Correct 365 ms 6736 KB Output is correct
26 Correct 372 ms 6744 KB Output is correct
27 Correct 376 ms 6704 KB Output is correct
28 Correct 390 ms 6700 KB Output is correct
29 Correct 381 ms 6488 KB Output is correct
30 Correct 381 ms 6696 KB Output is correct
31 Correct 377 ms 6700 KB Output is correct
32 Correct 418 ms 6872 KB Output is correct
33 Correct 349 ms 7008 KB Output is correct
34 Correct 309 ms 6696 KB Output is correct
35 Correct 155 ms 6492 KB Output is correct
36 Correct 248 ms 6744 KB Output is correct
37 Correct 163 ms 6708 KB Output is correct
38 Correct 250 ms 6744 KB Output is correct
39 Execution timed out 4022 ms 15340 KB Time limit exceeded
40 Halted 0 ms 0 KB -