답안 #915370

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
915370 2024-01-23T18:52:01 Z bobbilyking Meetings 2 (JOI21_meetings2) C++17
0 / 100
2 ms 5208 KB
#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';
    }
    
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 5208 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Incorrect 2 ms 4956 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 5208 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Incorrect 2 ms 4956 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 5208 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Incorrect 2 ms 4956 KB Output isn't correct
5 Halted 0 ms 0 KB -