제출 #915370

#제출 시각아이디문제언어결과실행 시간메모리
915370bobbilykingMeetings 2 (JOI21_meetings2)C++17
0 / 100
2 ms5208 KiB
#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #include<bits/stdc++.h> #include<math.h> using namespace std; typedef long long int ll; typedef long double ld; typedef pair<ll, ll> pl; typedef vector<ll> vl; #define FD(i, r, l) for(ll i = r; i > (l); --i) #define K first #define V second #define G(x) ll x; cin >> x; #define GD(x) ld x; cin >> x; #define GS(s) string s; cin >> s; #define EX(x) { cout << x << '\n'; exit(0); } #define A(a) (a).begin(), (a).end() #define F(i, l, r) for (ll i = l; i < (r); ++i) #define NN 200010 #define M 1000000007 // 998244353 vl adj[NN]; ll far = 1, dist; void dfs(ll i, ll p, ll d) { if (d > dist) { dist = d; far = i; } for (auto x: adj[i]) if (x-p) dfs(x, i, d+1); } int main(){ // freopen("a.in", "r", stdin); // freopen("a.out", "w", stdout); ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); G(n) F(i, 0, n-1) { G(x) G(y) adj[x].push_back(y); adj[y].push_back(x); } dfs(1, 1, 1); dist = 0; dfs(far, far, 1); F(i, 1, n+1) { if (i%2==1) cout << "1\n"; else cout << max(1ll, dist - i + 2) << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...