Submission #1093072

#TimeUsernameProblemLanguageResultExecution timeMemory
1093072vladiliusMeetings 2 (JOI21_meetings2)C++17
20 / 100
650 ms262144 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define pb push_back #define ff first #define ss second int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; vector<int> g[n + 1]; for (int i = 1; i < n; i++){ int x, y; cin>>x>>y; g[x].pb(y); g[y].pb(x); } vector<vector<int>> dist(n + 1, vector<int>(n + 1)); function<void(int, int, int, int&)> fill = [&](int v, int pr, int d, int& u){ dist[u][v] = d++; for (int i: g[v]){ if (i == pr) continue; fill(i, v, d, u); } }; for (int i = 1; i <= n; i++) fill(i, 0, 0, i); vector<vector<int>> sz(n + 1, vector<int>(n + 1)); function<void(int, int, int&)> fill_sz = [&](int v, int pr, int& u){ sz[u][v] = 1; for (int i: g[v]){ if (i == pr) continue; fill_sz(i, v, u); sz[u][v] += sz[u][i]; } }; for (int i = 1; i <= n; i++) fill_sz(i, 0, i); vector<int> p(n + 1, 1); for (int i = 1; i <= n; i++){ for (int j = i + 1; j <= n; j++){ int s = min(sz[i][j], sz[j][i]); p[s] = max(p[s], dist[i][j] + 1); } } for (int i = n - 1; i > 0; i--) p[i] = max(p[i], p[i + 1]); for (int x = 1; x <= n; x++){ if (x % 2){ cout<<1<<"\n"; continue; } cout<<p[x / 2]<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...