답안 #397716

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
397716 2021-05-02T23:07:07 Z AmineWeslati Meetings 2 (JOI21_meetings2) C++14
20 / 100
4000 ms 15308 KB
#include "bits/stdc++.h"
using namespace std;

typedef vector<int>vi;
#define pb push_back
#define FOR(i,a,b) for(int i=a; i<b; i++)
#define ROF(i,a,b) for(int i=b-1; i>=a; i--)

//-------------------------//

const int MX=2e5;
int N;
vi adj[MX];

vi sub(MX);

void ckmax(int &x, int y){
	x=max(x,y);
}

void dfs(int u, int p){
	sub[u]=1;
	for(int v: adj[u]) if(v!=p){
		dfs(v,u);
		sub[u]+=sub[v];
	}
}

vi val(MX,1);
void compute(int u, int p, int s, int d){
	ckmax(val[min(s,sub[u])],d+1);
	for(int v: adj[u]) if(v!=p) compute(v,u,s,d+1);
}

int main(){
	cin>>N;
	FOR(i,0,N-1){
		int u,v; cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}

	FOR(u,1,N+1){
		dfs(u,u);
		
		for(int v: adj[u]) compute(v,u,N-sub[v],1);
	}

	ROF(i,1,N){
		ckmax(val[i],val[i+1]);
	}
	FOR(i,1,N+1){
		if(i&1) cout << 1 << endl;
		else cout << val[i/2] << endl;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 6476 KB Output is correct
2 Correct 5 ms 6476 KB Output is correct
3 Correct 5 ms 6476 KB Output is correct
4 Correct 4 ms 6476 KB Output is correct
5 Correct 4 ms 6476 KB Output is correct
6 Correct 4 ms 6476 KB Output is correct
7 Correct 4 ms 6476 KB Output is correct
8 Correct 5 ms 6476 KB Output is correct
9 Correct 4 ms 6476 KB Output is correct
10 Correct 5 ms 6476 KB Output is correct
11 Correct 5 ms 6476 KB Output is correct
12 Correct 4 ms 6476 KB Output is correct
13 Correct 4 ms 6576 KB Output is correct
14 Correct 6 ms 6584 KB Output is correct
15 Correct 5 ms 6476 KB Output is correct
16 Correct 5 ms 6580 KB Output is correct
17 Correct 4 ms 6476 KB Output is correct
18 Correct 5 ms 6480 KB Output is correct
19 Correct 4 ms 6476 KB Output is correct
20 Correct 4 ms 6476 KB Output is correct
21 Correct 4 ms 6476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 6476 KB Output is correct
2 Correct 5 ms 6476 KB Output is correct
3 Correct 5 ms 6476 KB Output is correct
4 Correct 4 ms 6476 KB Output is correct
5 Correct 4 ms 6476 KB Output is correct
6 Correct 4 ms 6476 KB Output is correct
7 Correct 4 ms 6476 KB Output is correct
8 Correct 5 ms 6476 KB Output is correct
9 Correct 4 ms 6476 KB Output is correct
10 Correct 5 ms 6476 KB Output is correct
11 Correct 5 ms 6476 KB Output is correct
12 Correct 4 ms 6476 KB Output is correct
13 Correct 4 ms 6576 KB Output is correct
14 Correct 6 ms 6584 KB Output is correct
15 Correct 5 ms 6476 KB Output is correct
16 Correct 5 ms 6580 KB Output is correct
17 Correct 4 ms 6476 KB Output is correct
18 Correct 5 ms 6480 KB Output is correct
19 Correct 4 ms 6476 KB Output is correct
20 Correct 4 ms 6476 KB Output is correct
21 Correct 4 ms 6476 KB Output is correct
22 Correct 642 ms 6740 KB Output is correct
23 Correct 672 ms 6724 KB Output is correct
24 Correct 625 ms 6732 KB Output is correct
25 Correct 637 ms 6736 KB Output is correct
26 Correct 646 ms 6732 KB Output is correct
27 Correct 678 ms 6732 KB Output is correct
28 Correct 653 ms 6732 KB Output is correct
29 Correct 645 ms 6732 KB Output is correct
30 Correct 640 ms 6732 KB Output is correct
31 Correct 646 ms 6732 KB Output is correct
32 Correct 604 ms 6908 KB Output is correct
33 Correct 477 ms 7024 KB Output is correct
34 Correct 556 ms 6740 KB Output is correct
35 Correct 346 ms 6748 KB Output is correct
36 Correct 432 ms 6760 KB Output is correct
37 Correct 345 ms 6752 KB Output is correct
38 Correct 418 ms 6900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 6476 KB Output is correct
2 Correct 5 ms 6476 KB Output is correct
3 Correct 5 ms 6476 KB Output is correct
4 Correct 4 ms 6476 KB Output is correct
5 Correct 4 ms 6476 KB Output is correct
6 Correct 4 ms 6476 KB Output is correct
7 Correct 4 ms 6476 KB Output is correct
8 Correct 5 ms 6476 KB Output is correct
9 Correct 4 ms 6476 KB Output is correct
10 Correct 5 ms 6476 KB Output is correct
11 Correct 5 ms 6476 KB Output is correct
12 Correct 4 ms 6476 KB Output is correct
13 Correct 4 ms 6576 KB Output is correct
14 Correct 6 ms 6584 KB Output is correct
15 Correct 5 ms 6476 KB Output is correct
16 Correct 5 ms 6580 KB Output is correct
17 Correct 4 ms 6476 KB Output is correct
18 Correct 5 ms 6480 KB Output is correct
19 Correct 4 ms 6476 KB Output is correct
20 Correct 4 ms 6476 KB Output is correct
21 Correct 4 ms 6476 KB Output is correct
22 Correct 642 ms 6740 KB Output is correct
23 Correct 672 ms 6724 KB Output is correct
24 Correct 625 ms 6732 KB Output is correct
25 Correct 637 ms 6736 KB Output is correct
26 Correct 646 ms 6732 KB Output is correct
27 Correct 678 ms 6732 KB Output is correct
28 Correct 653 ms 6732 KB Output is correct
29 Correct 645 ms 6732 KB Output is correct
30 Correct 640 ms 6732 KB Output is correct
31 Correct 646 ms 6732 KB Output is correct
32 Correct 604 ms 6908 KB Output is correct
33 Correct 477 ms 7024 KB Output is correct
34 Correct 556 ms 6740 KB Output is correct
35 Correct 346 ms 6748 KB Output is correct
36 Correct 432 ms 6760 KB Output is correct
37 Correct 345 ms 6752 KB Output is correct
38 Correct 418 ms 6900 KB Output is correct
39 Execution timed out 4054 ms 15308 KB Time limit exceeded
40 Halted 0 ms 0 KB -