Submission #709776

#TimeUsernameProblemLanguageResultExecution timeMemory
709776Ronin13Meetings 2 (JOI21_meetings2)C++14
20 / 100
581 ms932 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...