답안 #1057757

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1057757 2024-08-14T05:30:25 Z 정희우(#11078) Infiltration (CCO24_day2problem1) C++17
6 / 25
2 ms 508 KB
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
using lint = long long;
using vint = vector<int>;
using pii = pair<int,int>;

const int MAX_N=105;

int n;
vint edge[MAX_N];
int pa[MAX_N];

int t=146;
vector<pii> moves[2]={
{{3,1},{13,0},{57,1}},
{{3,0},{13,1},{20,0},{37,1}}};

int dep(int v,int p,int d)
{
    int mxd=d;
    pa[v]=p;
    for(auto v0 : edge[v])
        if(v0!=p)
            mxd=max(mxd,dep(v0,v,d+1));
    return mxd;
}

int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin >> n;
    if(n!=100)return 1;
    for(int i=1;i<n;i++)
    {
        int u,v;
        cin >> u >> v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    dep(0,0,0);
    cout << 200 << '\n';
    for(int k=0;k<2;k++)
    {
        for(int i=0;i<n;i++)
        {
            int v=i;
            for(int j=0;j<100;j++)
            {
                if(k)cout << v << ' ';
                v=pa[v];
                cout << v << ' ';
                if(!k)cout << v << ' ';
            }
            cout << '\n';
        }
    }
    /*int root=0,d=dep(0,0,0);
    for(int i=0;i<n;i++)
    {
        int cd=dep(i,i,0);
        if(cd>=d)continue;
        root=i;d=cd;
    }
    dep(root,root,0);
    cout << t << '\n';
    for(int k=0;k<2;k++)
    {
        for(int i=0;i<n;i++)
        {
            int v=i;
            for(auto p : moves[k])
                for(int j=0;j<p.first;j++)
                {
                    if(k)cout << v << ' ';
                    if(p.second)v=pa[v];
                    cout << v << ' ';
                    if(!k)cout << v << ' ';
                }
            cout << '\n';
        }
    }*/
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 2 ms 348 KB Partially correct
2 Partially correct 2 ms 348 KB Partially correct
3 Partially correct 2 ms 348 KB Partially correct
4 Partially correct 2 ms 360 KB Partially correct
5 Partially correct 2 ms 348 KB Partially correct
6 Partially correct 2 ms 348 KB Partially correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Partially correct 1 ms 348 KB Partially correct
17 Partially correct 2 ms 348 KB Partially correct
18 Partially correct 1 ms 348 KB Partially correct
19 Partially correct 1 ms 348 KB Partially correct
20 Partially correct 2 ms 348 KB Partially correct
21 Partially correct 2 ms 348 KB Partially correct
22 Partially correct 2 ms 348 KB Partially correct
23 Partially correct 2 ms 508 KB Partially correct
24 Partially correct 2 ms 348 KB Partially correct
25 Partially correct 2 ms 344 KB Partially correct