Submission #1044079

# Submission time Handle Problem Language Result Execution time Memory
1044079 2024-08-05T07:10:25 Z vjudge1 Village (BOI20_village) C++17
75 / 100
39 ms 17352 KB
// 23 - 12 - 23 

#include<bits/stdc++.h>

using namespace std;

#define read() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define day() time_t now = time(0);char* x = ctime(&now);cerr<<"Right Now Is : "<<x<<"\n"

#define ii pair<int,int>
#define X first
#define Y second 

const long long MAX = (int)1e5 + 5;
const long long INF = (int)1e9;
const long long MOD = (int)1e9 + 7;

int n;
vector<int> adj[MAX];
int mxc[MAX];
int siz[MAX];
int mic[MAX];
int low = 0,high = 0;
vector<int> rt;

void dfs(int u = 1,int p = -1){
	siz[u] = 1;
	rt.push_back(u);
	for(auto v : adj[u]){
		if(v == p)continue;
		dfs(v,u);
		siz[u] += siz[v];
		high += min(n - siz[v],siz[v]);
	}
	
	if(u == mic[u]){
		if(p == -1)swap(mic[u],mic[adj[u][0]]);
		else swap(mic[u],mic[p]);
		low += 2;
	}
}
signed main(){
	
	read();
	
	cin >> n;
	
	for(int i = 1,u,v;i < n;i++){
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}	
	
	for(int i = 1;i <= n;i++){
		mic[i] = i;
		mxc[i] = i;
	}
	dfs();
	for(int i = 1;i <= n;i++){
		int u = rt[i - 1];
		int v = rt[(i - 1 + n / 2) % n];
		mxc[u] = v;
	}
	
	cout << low << " " << high * 2 << '\n';
	for(int i = 1;i <= n;i++)cout << mic[i] << " \n"[i == n];
	for(int i = 1;i <= n;i++)cout << mxc[i] << " \n"[i == n];
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 3676 KB Output is correct
2 Correct 1 ms 3676 KB Output is correct
3 Correct 1 ms 3676 KB Output is correct
4 Correct 1 ms 3676 KB Output is correct
5 Correct 1 ms 3676 KB Output is correct
6 Correct 1 ms 3676 KB Output is correct
7 Correct 1 ms 3676 KB Output is correct
8 Correct 1 ms 3676 KB Output is correct
9 Correct 1 ms 3676 KB Output is correct
10 Correct 1 ms 3676 KB Output is correct
11 Correct 1 ms 3676 KB Output is correct
12 Correct 1 ms 3760 KB Output is correct
13 Correct 1 ms 3672 KB Output is correct
14 Correct 1 ms 3672 KB Output is correct
15 Correct 1 ms 3676 KB Output is correct
16 Correct 1 ms 3676 KB Output is correct
17 Correct 1 ms 3768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3672 KB Output is correct
2 Correct 1 ms 3676 KB Output is correct
3 Correct 1 ms 3804 KB Output is correct
4 Correct 2 ms 3676 KB Output is correct
5 Correct 1 ms 3676 KB Output is correct
6 Correct 2 ms 3932 KB Output is correct
7 Correct 2 ms 3672 KB Output is correct
8 Correct 1 ms 3676 KB Output is correct
9 Correct 1 ms 3676 KB Output is correct
10 Correct 1 ms 3676 KB Output is correct
11 Correct 1 ms 3676 KB Output is correct
12 Correct 1 ms 3676 KB Output is correct
13 Correct 1 ms 3676 KB Output is correct
14 Correct 1 ms 3676 KB Output is correct
15 Correct 1 ms 3676 KB Output is correct
16 Correct 2 ms 3804 KB Output is correct
17 Correct 1 ms 3676 KB Output is correct
18 Correct 1 ms 3676 KB Output is correct
19 Correct 1 ms 3676 KB Output is correct
20 Correct 2 ms 3672 KB Output is correct
21 Correct 1 ms 3676 KB Output is correct
22 Correct 1 ms 3856 KB Output is correct
23 Correct 1 ms 3676 KB Output is correct
24 Correct 1 ms 3676 KB Output is correct
25 Correct 1 ms 3676 KB Output is correct
26 Correct 1 ms 3676 KB Output is correct
27 Correct 1 ms 3676 KB Output is correct
28 Correct 1 ms 3676 KB Output is correct
29 Correct 1 ms 3676 KB Output is correct
30 Correct 1 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3676 KB Output is correct
2 Correct 1 ms 3676 KB Output is correct
3 Correct 1 ms 3676 KB Output is correct
4 Correct 1 ms 3676 KB Output is correct
5 Correct 1 ms 3676 KB Output is correct
6 Correct 1 ms 3676 KB Output is correct
7 Correct 1 ms 3676 KB Output is correct
8 Correct 1 ms 3676 KB Output is correct
9 Correct 1 ms 3676 KB Output is correct
10 Correct 1 ms 3676 KB Output is correct
11 Correct 1 ms 3676 KB Output is correct
12 Correct 1 ms 3760 KB Output is correct
13 Correct 1 ms 3672 KB Output is correct
14 Correct 1 ms 3672 KB Output is correct
15 Correct 1 ms 3676 KB Output is correct
16 Correct 1 ms 3676 KB Output is correct
17 Correct 1 ms 3768 KB Output is correct
18 Correct 1 ms 3672 KB Output is correct
19 Correct 1 ms 3676 KB Output is correct
20 Correct 1 ms 3804 KB Output is correct
21 Correct 2 ms 3676 KB Output is correct
22 Correct 1 ms 3676 KB Output is correct
23 Correct 2 ms 3932 KB Output is correct
24 Correct 2 ms 3672 KB Output is correct
25 Correct 1 ms 3676 KB Output is correct
26 Correct 1 ms 3676 KB Output is correct
27 Correct 1 ms 3676 KB Output is correct
28 Correct 1 ms 3676 KB Output is correct
29 Correct 1 ms 3676 KB Output is correct
30 Correct 1 ms 3676 KB Output is correct
31 Correct 1 ms 3676 KB Output is correct
32 Correct 1 ms 3676 KB Output is correct
33 Correct 2 ms 3804 KB Output is correct
34 Correct 1 ms 3676 KB Output is correct
35 Correct 1 ms 3676 KB Output is correct
36 Correct 1 ms 3676 KB Output is correct
37 Correct 2 ms 3672 KB Output is correct
38 Correct 1 ms 3676 KB Output is correct
39 Correct 1 ms 3856 KB Output is correct
40 Correct 1 ms 3676 KB Output is correct
41 Correct 1 ms 3676 KB Output is correct
42 Correct 1 ms 3676 KB Output is correct
43 Correct 1 ms 3676 KB Output is correct
44 Correct 1 ms 3676 KB Output is correct
45 Correct 1 ms 3676 KB Output is correct
46 Correct 1 ms 3676 KB Output is correct
47 Correct 1 ms 3676 KB Output is correct
48 Correct 26 ms 9368 KB Output is correct
49 Correct 32 ms 10052 KB Output is correct
50 Correct 30 ms 9876 KB Output is correct
51 Correct 23 ms 8652 KB Output is correct
52 Correct 29 ms 9900 KB Output is correct
53 Correct 26 ms 9428 KB Output is correct
54 Correct 21 ms 10508 KB Output is correct
55 Partially correct 32 ms 17352 KB Partially correct
56 Partially correct 32 ms 13512 KB Partially correct
57 Correct 39 ms 12236 KB Output is correct
58 Correct 29 ms 11088 KB Output is correct
59 Correct 27 ms 9932 KB Output is correct
60 Correct 26 ms 10060 KB Output is correct
61 Correct 31 ms 10188 KB Output is correct
62 Correct 35 ms 10440 KB Output is correct
63 Correct 29 ms 10016 KB Output is correct
64 Correct 26 ms 10192 KB Output is correct
65 Correct 25 ms 10460 KB Output is correct
66 Correct 23 ms 9944 KB Output is correct
67 Correct 19 ms 8660 KB Output is correct
68 Correct 27 ms 9344 KB Output is correct
69 Correct 25 ms 10440 KB Output is correct
70 Correct 25 ms 9932 KB Output is correct
71 Correct 18 ms 8404 KB Output is correct
72 Correct 19 ms 9164 KB Output is correct
73 Correct 25 ms 10440 KB Output is correct
74 Correct 22 ms 9764 KB Output is correct
75 Correct 29 ms 9936 KB Output is correct
76 Correct 30 ms 9936 KB Output is correct
77 Correct 26 ms 10188 KB Output is correct
78 Correct 19 ms 7964 KB Output is correct
79 Correct 23 ms 8656 KB Output is correct
80 Correct 28 ms 9972 KB Output is correct
81 Correct 27 ms 10196 KB Output is correct
82 Correct 27 ms 10188 KB Output is correct