Submission #709773

# Submission time Handle Problem Language Result Execution time Memory
709773 2023-03-14T11:54:38 Z Ronin13 Meetings 2 (JOI21_meetings2) C++14
0 / 100
1 ms 340 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];

int ans[nmax];
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){
    ans[min(sz[v] * 2, x * 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;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -