답안 #415844

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
415844 2021-06-01T15:39:19 Z nicolaalexandra Village (BOI20_village) C++14
50 / 100
167 ms 15020 KB
#include <bits/stdc++.h>
#define DIM 100010
#define INF 2000000000
using namespace std;

vector <int> L[DIM];
int v[DIM],fth[DIM];
int n,i,x,y,sol_min;


void dfs (int nod, int tata){
    fth[nod] = tata;
    for (auto vecin : L[nod])
        if (vecin != tata)
            dfs (vecin,nod);

    if (nod != 1 && v[nod] == nod){

        sol_min += 2;
        swap (v[nod],v[fth[nod]]);

    }

}


int main (){

    //ifstream cin ("date.in");
    //ofstream cout ("date.out");

    cin>>n;
    for (i=1;i<n;i++){
        cin>>x>>y;
        L[x].push_back(y);
        L[y].push_back(x);
    }

    for (i=1;i<=n;i++)
        v[i] = i;

    dfs (1,0);

    for (i=1;i<=n;i++)
        if (v[i] == i){
            sol_min += 2;
            if (i != 1)
                swap (v[i],v[fth[i]]);
            else swap (v[i],v[L[1][0]]);
        }

    cout<<sol_min<<" "<<0<<"\n";
    for (i=1;i<=n;i++)
        cout<<v[i]<<" ";

    cout<<"\n";

    for (i=1;i<=n;i++)
        cout<<v[i]<<" ";


    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 3 ms 2636 KB Partially correct
2 Partially correct 3 ms 2648 KB Partially correct
3 Partially correct 2 ms 2644 KB Partially correct
4 Partially correct 2 ms 2636 KB Partially correct
5 Partially correct 2 ms 2648 KB Partially correct
6 Partially correct 2 ms 2656 KB Partially correct
7 Partially correct 2 ms 2636 KB Partially correct
8 Partially correct 2 ms 2636 KB Partially correct
9 Partially correct 2 ms 2648 KB Partially correct
10 Partially correct 2 ms 2648 KB Partially correct
11 Partially correct 3 ms 2636 KB Partially correct
12 Partially correct 2 ms 2636 KB Partially correct
13 Partially correct 3 ms 2636 KB Partially correct
14 Partially correct 2 ms 2636 KB Partially correct
15 Partially correct 3 ms 2636 KB Partially correct
16 Partially correct 2 ms 2636 KB Partially correct
17 Partially correct 3 ms 2648 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 3 ms 2636 KB Partially correct
2 Partially correct 3 ms 2636 KB Partially correct
3 Partially correct 3 ms 2636 KB Partially correct
4 Partially correct 4 ms 2636 KB Partially correct
5 Partially correct 4 ms 2636 KB Partially correct
6 Partially correct 4 ms 2636 KB Partially correct
7 Partially correct 4 ms 2660 KB Partially correct
8 Partially correct 4 ms 2652 KB Partially correct
9 Partially correct 3 ms 2636 KB Partially correct
10 Partially correct 3 ms 2636 KB Partially correct
11 Partially correct 4 ms 2652 KB Partially correct
12 Partially correct 3 ms 2636 KB Partially correct
13 Partially correct 4 ms 2636 KB Partially correct
14 Partially correct 4 ms 2636 KB Partially correct
15 Partially correct 3 ms 2652 KB Partially correct
16 Partially correct 3 ms 2656 KB Partially correct
17 Partially correct 4 ms 2636 KB Partially correct
18 Partially correct 3 ms 2636 KB Partially correct
19 Partially correct 3 ms 2636 KB Partially correct
20 Partially correct 3 ms 2652 KB Partially correct
21 Partially correct 3 ms 2652 KB Partially correct
22 Partially correct 4 ms 2636 KB Partially correct
23 Partially correct 4 ms 2656 KB Partially correct
24 Partially correct 3 ms 2636 KB Partially correct
25 Partially correct 5 ms 2656 KB Partially correct
26 Partially correct 4 ms 2636 KB Partially correct
27 Partially correct 3 ms 2636 KB Partially correct
28 Partially correct 3 ms 2636 KB Partially correct
29 Partially correct 3 ms 2636 KB Partially correct
30 Partially correct 4 ms 2636 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 3 ms 2636 KB Partially correct
2 Partially correct 3 ms 2648 KB Partially correct
3 Partially correct 2 ms 2644 KB Partially correct
4 Partially correct 2 ms 2636 KB Partially correct
5 Partially correct 2 ms 2648 KB Partially correct
6 Partially correct 2 ms 2656 KB Partially correct
7 Partially correct 2 ms 2636 KB Partially correct
8 Partially correct 2 ms 2636 KB Partially correct
9 Partially correct 2 ms 2648 KB Partially correct
10 Partially correct 2 ms 2648 KB Partially correct
11 Partially correct 3 ms 2636 KB Partially correct
12 Partially correct 2 ms 2636 KB Partially correct
13 Partially correct 3 ms 2636 KB Partially correct
14 Partially correct 2 ms 2636 KB Partially correct
15 Partially correct 3 ms 2636 KB Partially correct
16 Partially correct 2 ms 2636 KB Partially correct
17 Partially correct 3 ms 2648 KB Partially correct
18 Partially correct 3 ms 2636 KB Partially correct
19 Partially correct 3 ms 2636 KB Partially correct
20 Partially correct 3 ms 2636 KB Partially correct
21 Partially correct 4 ms 2636 KB Partially correct
22 Partially correct 4 ms 2636 KB Partially correct
23 Partially correct 4 ms 2636 KB Partially correct
24 Partially correct 4 ms 2660 KB Partially correct
25 Partially correct 4 ms 2652 KB Partially correct
26 Partially correct 3 ms 2636 KB Partially correct
27 Partially correct 3 ms 2636 KB Partially correct
28 Partially correct 4 ms 2652 KB Partially correct
29 Partially correct 3 ms 2636 KB Partially correct
30 Partially correct 4 ms 2636 KB Partially correct
31 Partially correct 4 ms 2636 KB Partially correct
32 Partially correct 3 ms 2652 KB Partially correct
33 Partially correct 3 ms 2656 KB Partially correct
34 Partially correct 4 ms 2636 KB Partially correct
35 Partially correct 3 ms 2636 KB Partially correct
36 Partially correct 3 ms 2636 KB Partially correct
37 Partially correct 3 ms 2652 KB Partially correct
38 Partially correct 3 ms 2652 KB Partially correct
39 Partially correct 4 ms 2636 KB Partially correct
40 Partially correct 4 ms 2656 KB Partially correct
41 Partially correct 3 ms 2636 KB Partially correct
42 Partially correct 5 ms 2656 KB Partially correct
43 Partially correct 4 ms 2636 KB Partially correct
44 Partially correct 3 ms 2636 KB Partially correct
45 Partially correct 3 ms 2636 KB Partially correct
46 Partially correct 3 ms 2636 KB Partially correct
47 Partially correct 4 ms 2636 KB Partially correct
48 Partially correct 122 ms 8552 KB Partially correct
49 Partially correct 126 ms 8900 KB Partially correct
50 Partially correct 137 ms 9084 KB Partially correct
51 Partially correct 87 ms 7560 KB Partially correct
52 Partially correct 110 ms 8892 KB Partially correct
53 Partially correct 114 ms 8348 KB Partially correct
54 Partially correct 61 ms 8476 KB Partially correct
55 Partially correct 167 ms 15020 KB Partially correct
56 Partially correct 121 ms 11752 KB Partially correct
57 Partially correct 135 ms 10820 KB Partially correct
58 Partially correct 128 ms 9976 KB Partially correct
59 Partially correct 114 ms 9028 KB Partially correct
60 Partially correct 140 ms 9148 KB Partially correct
61 Partially correct 112 ms 9364 KB Partially correct
62 Partially correct 105 ms 9380 KB Partially correct
63 Partially correct 101 ms 8920 KB Partially correct
64 Partially correct 123 ms 9288 KB Partially correct
65 Partially correct 131 ms 9352 KB Partially correct
66 Partially correct 105 ms 8996 KB Partially correct
67 Partially correct 84 ms 7540 KB Partially correct
68 Partially correct 99 ms 8368 KB Partially correct
69 Partially correct 119 ms 9452 KB Partially correct
70 Partially correct 102 ms 8948 KB Partially correct
71 Partially correct 74 ms 7340 KB Partially correct
72 Partially correct 93 ms 7948 KB Partially correct
73 Partially correct 119 ms 9464 KB Partially correct
74 Partially correct 96 ms 8800 KB Partially correct
75 Partially correct 117 ms 8900 KB Partially correct
76 Partially correct 126 ms 8832 KB Partially correct
77 Partially correct 128 ms 9028 KB Partially correct
78 Partially correct 81 ms 6896 KB Partially correct
79 Partially correct 105 ms 7536 KB Partially correct
80 Partially correct 116 ms 8772 KB Partially correct
81 Partially correct 119 ms 9284 KB Partially correct
82 Partially correct 119 ms 9288 KB Partially correct