답안 #709776

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709776 2023-03-14T12:00:19 Z Ronin13 Meetings 2 (JOI21_meetings2) C++14
20 / 100
581 ms 932 KB
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
const int nmax = 5001;
vector <vector <int> > g(nmax);
vector <int> vec;
int a[nmax], h[nmax];
int sz[nmax];

vector <int> ans(nmax, 1);
int n;
void dfs(int v, int e = -1){
    sz[v] = 1;
    for(int to : g[v]){
        if(to == e) continue;
        dfs(to, v);
        sz[v] += sz[to];
    }
}

void DFS(int v, int d, int x, int e = -1){
    int l = min(sz[v],x);
    ans[l * 2] = max(ans[l * 2], d + 2);
    for(int to : g[v]){
        if(to == e) continue;
        DFS(to, d + 1, x, v);
    }
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for(int  i = 1; i < n; i++){
        int u, v; cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    for(int i = 1; i <= n; i++){
        dfs(i);
        for(int to : g[i]){
            DFS(to, 0, n - sz[to], i);
        }
    }
    for(int i = n; i >= 1; i--){
        if(i % 2 == 1)
            ans[i] = 1;
        else ans[i] = max(ans[i], ans[i + 2]);
    }
    for(int i = 1; i <= n; i++)
        cout << ans[i] << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 0 ms 460 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 0 ms 460 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 562 ms 624 KB Output is correct
23 Correct 546 ms 620 KB Output is correct
24 Correct 530 ms 716 KB Output is correct
25 Correct 561 ms 628 KB Output is correct
26 Correct 544 ms 532 KB Output is correct
27 Correct 564 ms 640 KB Output is correct
28 Correct 571 ms 628 KB Output is correct
29 Correct 567 ms 632 KB Output is correct
30 Correct 557 ms 640 KB Output is correct
31 Correct 574 ms 624 KB Output is correct
32 Correct 581 ms 800 KB Output is correct
33 Correct 485 ms 932 KB Output is correct
34 Correct 479 ms 596 KB Output is correct
35 Correct 284 ms 644 KB Output is correct
36 Correct 393 ms 660 KB Output is correct
37 Correct 289 ms 596 KB Output is correct
38 Correct 385 ms 780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 0 ms 460 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 562 ms 624 KB Output is correct
23 Correct 546 ms 620 KB Output is correct
24 Correct 530 ms 716 KB Output is correct
25 Correct 561 ms 628 KB Output is correct
26 Correct 544 ms 532 KB Output is correct
27 Correct 564 ms 640 KB Output is correct
28 Correct 571 ms 628 KB Output is correct
29 Correct 567 ms 632 KB Output is correct
30 Correct 557 ms 640 KB Output is correct
31 Correct 574 ms 624 KB Output is correct
32 Correct 581 ms 800 KB Output is correct
33 Correct 485 ms 932 KB Output is correct
34 Correct 479 ms 596 KB Output is correct
35 Correct 284 ms 644 KB Output is correct
36 Correct 393 ms 660 KB Output is correct
37 Correct 289 ms 596 KB Output is correct
38 Correct 385 ms 780 KB Output is correct
39 Runtime error 1 ms 724 KB Execution killed with signal 11
40 Halted 0 ms 0 KB -