답안 #1037204

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1037204 2024-07-28T10:41:39 Z MMihalev Village (BOI20_village) C++14
50 / 100
57 ms 15700 KB
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<tuple>
#include<set>
#include<map>
#include<random>
#include<chrono>
using namespace std;
const int MAX_N=1e5+5;
int n;
vector<int>g[MAX_N];
int ans[MAX_N];
int all;
bool dfs(int u,int par)
{
    bool nowswapped=0;
    for(int v:g[u])
    {
        if(v==par)continue;
        bool swapped=dfs(v,u);
        if(swapped)continue;
        swap(ans[v],ans[u]);
        all+=2;
        nowswapped=1;
    }
    if(nowswapped+par==0)
    {
        swap(ans[u],ans[g[u][0]]);
        all+=2;
        nowswapped=1;
    }
    return nowswapped;
}
signed main()
{
    cin>>n;
    ans[n]=n;
    for(int i=1;i<n;i++)
    {
        ans[i]=i;
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1,0);
    cout<<all<<" "<<0<<"\n";
    for(int i=1;i<=n;i++)
    {
        cout<<ans[i]<<" ";
    }
    cout<<"\n";
    for(int i=1;i<=n;i++)
    {
        cout<<1<<" ";
    }
    cout<<"\n";
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 2904 KB Partially correct
2 Partially correct 1 ms 2908 KB Partially correct
3 Partially correct 1 ms 2908 KB Partially correct
4 Partially correct 1 ms 2908 KB Partially correct
5 Partially correct 1 ms 2908 KB Partially correct
6 Partially correct 1 ms 2908 KB Partially correct
7 Partially correct 1 ms 2908 KB Partially correct
8 Partially correct 1 ms 2908 KB Partially correct
9 Partially correct 1 ms 2908 KB Partially correct
10 Partially correct 1 ms 2908 KB Partially correct
11 Partially correct 1 ms 2908 KB Partially correct
12 Partially correct 1 ms 2908 KB Partially correct
13 Partially correct 1 ms 2908 KB Partially correct
14 Partially correct 1 ms 2908 KB Partially correct
15 Partially correct 1 ms 2908 KB Partially correct
16 Partially correct 1 ms 2996 KB Partially correct
17 Partially correct 1 ms 2908 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 2908 KB Partially correct
2 Partially correct 1 ms 2908 KB Partially correct
3 Partially correct 1 ms 2908 KB Partially correct
4 Partially correct 1 ms 2908 KB Partially correct
5 Partially correct 1 ms 2908 KB Partially correct
6 Partially correct 1 ms 2908 KB Partially correct
7 Partially correct 1 ms 2908 KB Partially correct
8 Partially correct 1 ms 2908 KB Partially correct
9 Partially correct 1 ms 2908 KB Partially correct
10 Partially correct 1 ms 2908 KB Partially correct
11 Partially correct 1 ms 3164 KB Partially correct
12 Partially correct 1 ms 2908 KB Partially correct
13 Partially correct 1 ms 3056 KB Partially correct
14 Partially correct 1 ms 2908 KB Partially correct
15 Partially correct 1 ms 3048 KB Partially correct
16 Partially correct 1 ms 2908 KB Partially correct
17 Partially correct 1 ms 3164 KB Partially correct
18 Partially correct 1 ms 2908 KB Partially correct
19 Partially correct 1 ms 2908 KB Partially correct
20 Partially correct 1 ms 2908 KB Partially correct
21 Partially correct 1 ms 2908 KB Partially correct
22 Partially correct 1 ms 2908 KB Partially correct
23 Partially correct 1 ms 2908 KB Partially correct
24 Partially correct 1 ms 2908 KB Partially correct
25 Partially correct 1 ms 2908 KB Partially correct
26 Partially correct 1 ms 2908 KB Partially correct
27 Partially correct 1 ms 2908 KB Partially correct
28 Partially correct 1 ms 2908 KB Partially correct
29 Partially correct 1 ms 2908 KB Partially correct
30 Partially correct 1 ms 2908 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 2904 KB Partially correct
2 Partially correct 1 ms 2908 KB Partially correct
3 Partially correct 1 ms 2908 KB Partially correct
4 Partially correct 1 ms 2908 KB Partially correct
5 Partially correct 1 ms 2908 KB Partially correct
6 Partially correct 1 ms 2908 KB Partially correct
7 Partially correct 1 ms 2908 KB Partially correct
8 Partially correct 1 ms 2908 KB Partially correct
9 Partially correct 1 ms 2908 KB Partially correct
10 Partially correct 1 ms 2908 KB Partially correct
11 Partially correct 1 ms 2908 KB Partially correct
12 Partially correct 1 ms 2908 KB Partially correct
13 Partially correct 1 ms 2908 KB Partially correct
14 Partially correct 1 ms 2908 KB Partially correct
15 Partially correct 1 ms 2908 KB Partially correct
16 Partially correct 1 ms 2996 KB Partially correct
17 Partially correct 1 ms 2908 KB Partially correct
18 Partially correct 1 ms 2908 KB Partially correct
19 Partially correct 1 ms 2908 KB Partially correct
20 Partially correct 1 ms 2908 KB Partially correct
21 Partially correct 1 ms 2908 KB Partially correct
22 Partially correct 1 ms 2908 KB Partially correct
23 Partially correct 1 ms 2908 KB Partially correct
24 Partially correct 1 ms 2908 KB Partially correct
25 Partially correct 1 ms 2908 KB Partially correct
26 Partially correct 1 ms 2908 KB Partially correct
27 Partially correct 1 ms 2908 KB Partially correct
28 Partially correct 1 ms 3164 KB Partially correct
29 Partially correct 1 ms 2908 KB Partially correct
30 Partially correct 1 ms 3056 KB Partially correct
31 Partially correct 1 ms 2908 KB Partially correct
32 Partially correct 1 ms 3048 KB Partially correct
33 Partially correct 1 ms 2908 KB Partially correct
34 Partially correct 1 ms 3164 KB Partially correct
35 Partially correct 1 ms 2908 KB Partially correct
36 Partially correct 1 ms 2908 KB Partially correct
37 Partially correct 1 ms 2908 KB Partially correct
38 Partially correct 1 ms 2908 KB Partially correct
39 Partially correct 1 ms 2908 KB Partially correct
40 Partially correct 1 ms 2908 KB Partially correct
41 Partially correct 1 ms 2908 KB Partially correct
42 Partially correct 1 ms 2908 KB Partially correct
43 Partially correct 1 ms 2908 KB Partially correct
44 Partially correct 1 ms 2908 KB Partially correct
45 Partially correct 1 ms 2908 KB Partially correct
46 Partially correct 1 ms 2908 KB Partially correct
47 Partially correct 1 ms 2908 KB Partially correct
48 Partially correct 49 ms 7904 KB Partially correct
49 Partially correct 52 ms 8276 KB Partially correct
50 Partially correct 56 ms 8280 KB Partially correct
51 Partially correct 41 ms 6976 KB Partially correct
52 Partially correct 52 ms 8112 KB Partially correct
53 Partially correct 47 ms 7584 KB Partially correct
54 Partially correct 31 ms 9032 KB Partially correct
55 Partially correct 57 ms 15700 KB Partially correct
56 Partially correct 53 ms 11604 KB Partially correct
57 Partially correct 54 ms 10576 KB Partially correct
58 Partially correct 55 ms 9300 KB Partially correct
59 Partially correct 51 ms 8276 KB Partially correct
60 Partially correct 52 ms 8396 KB Partially correct
61 Partially correct 50 ms 8668 KB Partially correct
62 Partially correct 50 ms 8600 KB Partially correct
63 Partially correct 47 ms 8276 KB Partially correct
64 Partially correct 50 ms 8536 KB Partially correct
65 Partially correct 48 ms 8788 KB Partially correct
66 Partially correct 45 ms 8276 KB Partially correct
67 Partially correct 36 ms 6996 KB Partially correct
68 Partially correct 42 ms 7760 KB Partially correct
69 Partially correct 48 ms 8788 KB Partially correct
70 Partially correct 44 ms 8276 KB Partially correct
71 Partially correct 36 ms 6996 KB Partially correct
72 Partially correct 38 ms 7508 KB Partially correct
73 Partially correct 52 ms 8792 KB Partially correct
74 Partially correct 44 ms 8128 KB Partially correct
75 Partially correct 55 ms 8020 KB Partially correct
76 Partially correct 51 ms 8076 KB Partially correct
77 Partially correct 52 ms 8472 KB Partially correct
78 Partially correct 34 ms 6484 KB Partially correct
79 Partially correct 39 ms 7252 KB Partially correct
80 Partially correct 56 ms 8044 KB Partially correct
81 Partially correct 49 ms 8584 KB Partially correct
82 Partially correct 48 ms 8540 KB Partially correct