답안 #926075

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
926075 2024-02-12T14:28:50 Z andrei_boaca Meetings 2 (JOI21_meetings2) C++17
20 / 100
4000 ms 17748 KB
#include <bits/stdc++.h>

using namespace std;
int n,sol[200005],par[200005],reprez[200005],niv[200005],nr[200005];
vector<int> muchii[200005];
void dfs(int nod)
{
    nr[nod]=1;
    for(int i:muchii[nod])
        if(i!=par[nod])
        {
            par[i]=nod;
            niv[i]=niv[nod]+1;
            if(reprez[nod]==0)
                reprez[i]=i;
            else
                reprez[i]=reprez[nod];
            dfs(i);
            nr[nod]+=nr[i];
        }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        muchii[a].push_back(b);
        muchii[b].push_back(a);
    }
    for(int i=1;i<=n;i++)
        sol[i]=1;
    for(int i=1;i<=n;i++)
    {
        par[i]=0;
        reprez[i]=0;
        niv[i]=1;
        dfs(i);
        for(int j=1;j<=n;j++)
            if(j!=i)
            {
                int poz=2*min(n-nr[reprez[j]],nr[j]);
                int lg=niv[j];
                sol[poz]=max(sol[poz],lg);
            }
    }
    for(int i=(n/2)*2;i>0;i-=2)
        sol[i]=max(sol[i],sol[i+2]);
    for(int i=1;i<=n;i++)
        cout<<sol[i]<<'\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8796 KB Output is correct
2 Correct 2 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 2 ms 8796 KB Output is correct
5 Correct 2 ms 8796 KB Output is correct
6 Correct 2 ms 8852 KB Output is correct
7 Correct 1 ms 8796 KB Output is correct
8 Correct 2 ms 8796 KB Output is correct
9 Correct 2 ms 8796 KB Output is correct
10 Correct 2 ms 8792 KB Output is correct
11 Correct 2 ms 8796 KB Output is correct
12 Correct 1 ms 8796 KB Output is correct
13 Correct 2 ms 8796 KB Output is correct
14 Correct 2 ms 8796 KB Output is correct
15 Correct 1 ms 8796 KB Output is correct
16 Correct 1 ms 8796 KB Output is correct
17 Correct 2 ms 8796 KB Output is correct
18 Correct 2 ms 8796 KB Output is correct
19 Correct 1 ms 8796 KB Output is correct
20 Correct 2 ms 8796 KB Output is correct
21 Correct 2 ms 8796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8796 KB Output is correct
2 Correct 2 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 2 ms 8796 KB Output is correct
5 Correct 2 ms 8796 KB Output is correct
6 Correct 2 ms 8852 KB Output is correct
7 Correct 1 ms 8796 KB Output is correct
8 Correct 2 ms 8796 KB Output is correct
9 Correct 2 ms 8796 KB Output is correct
10 Correct 2 ms 8792 KB Output is correct
11 Correct 2 ms 8796 KB Output is correct
12 Correct 1 ms 8796 KB Output is correct
13 Correct 2 ms 8796 KB Output is correct
14 Correct 2 ms 8796 KB Output is correct
15 Correct 1 ms 8796 KB Output is correct
16 Correct 1 ms 8796 KB Output is correct
17 Correct 2 ms 8796 KB Output is correct
18 Correct 2 ms 8796 KB Output is correct
19 Correct 1 ms 8796 KB Output is correct
20 Correct 2 ms 8796 KB Output is correct
21 Correct 2 ms 8796 KB Output is correct
22 Correct 189 ms 9000 KB Output is correct
23 Correct 203 ms 8996 KB Output is correct
24 Correct 203 ms 8796 KB Output is correct
25 Correct 193 ms 8796 KB Output is correct
26 Correct 187 ms 9004 KB Output is correct
27 Correct 192 ms 8796 KB Output is correct
28 Correct 200 ms 8996 KB Output is correct
29 Correct 196 ms 9008 KB Output is correct
30 Correct 185 ms 8796 KB Output is correct
31 Correct 203 ms 9000 KB Output is correct
32 Correct 238 ms 9048 KB Output is correct
33 Correct 225 ms 9304 KB Output is correct
34 Correct 167 ms 8792 KB Output is correct
35 Correct 150 ms 8792 KB Output is correct
36 Correct 206 ms 8796 KB Output is correct
37 Correct 150 ms 8792 KB Output is correct
38 Correct 187 ms 9048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8796 KB Output is correct
2 Correct 2 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 2 ms 8796 KB Output is correct
5 Correct 2 ms 8796 KB Output is correct
6 Correct 2 ms 8852 KB Output is correct
7 Correct 1 ms 8796 KB Output is correct
8 Correct 2 ms 8796 KB Output is correct
9 Correct 2 ms 8796 KB Output is correct
10 Correct 2 ms 8792 KB Output is correct
11 Correct 2 ms 8796 KB Output is correct
12 Correct 1 ms 8796 KB Output is correct
13 Correct 2 ms 8796 KB Output is correct
14 Correct 2 ms 8796 KB Output is correct
15 Correct 1 ms 8796 KB Output is correct
16 Correct 1 ms 8796 KB Output is correct
17 Correct 2 ms 8796 KB Output is correct
18 Correct 2 ms 8796 KB Output is correct
19 Correct 1 ms 8796 KB Output is correct
20 Correct 2 ms 8796 KB Output is correct
21 Correct 2 ms 8796 KB Output is correct
22 Correct 189 ms 9000 KB Output is correct
23 Correct 203 ms 8996 KB Output is correct
24 Correct 203 ms 8796 KB Output is correct
25 Correct 193 ms 8796 KB Output is correct
26 Correct 187 ms 9004 KB Output is correct
27 Correct 192 ms 8796 KB Output is correct
28 Correct 200 ms 8996 KB Output is correct
29 Correct 196 ms 9008 KB Output is correct
30 Correct 185 ms 8796 KB Output is correct
31 Correct 203 ms 9000 KB Output is correct
32 Correct 238 ms 9048 KB Output is correct
33 Correct 225 ms 9304 KB Output is correct
34 Correct 167 ms 8792 KB Output is correct
35 Correct 150 ms 8792 KB Output is correct
36 Correct 206 ms 8796 KB Output is correct
37 Correct 150 ms 8792 KB Output is correct
38 Correct 187 ms 9048 KB Output is correct
39 Execution timed out 4043 ms 17748 KB Time limit exceeded
40 Halted 0 ms 0 KB -