Submission #397716

#TimeUsernameProblemLanguageResultExecution timeMemory
397716AmineWeslatiMeetings 2 (JOI21_meetings2)C++14
20 / 100
4054 ms15308 KiB
#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; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...