# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1044085 |
2024-08-05T07:12:17 Z |
vjudge1 |
Village (BOI20_village) |
C++17 |
|
55 ms |
17864 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 int long long
#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 |
4956 KB |
Output is correct |
2 |
Correct |
1 ms |
4956 KB |
Output is correct |
3 |
Correct |
1 ms |
4956 KB |
Output is correct |
4 |
Correct |
1 ms |
4956 KB |
Output is correct |
5 |
Correct |
1 ms |
4956 KB |
Output is correct |
6 |
Correct |
1 ms |
4956 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
8 |
Correct |
1 ms |
4956 KB |
Output is correct |
9 |
Correct |
1 ms |
4956 KB |
Output is correct |
10 |
Correct |
1 ms |
4956 KB |
Output is correct |
11 |
Correct |
1 ms |
4956 KB |
Output is correct |
12 |
Correct |
1 ms |
4956 KB |
Output is correct |
13 |
Correct |
1 ms |
4956 KB |
Output is correct |
14 |
Correct |
1 ms |
4956 KB |
Output is correct |
15 |
Correct |
1 ms |
4956 KB |
Output is correct |
16 |
Correct |
1 ms |
4956 KB |
Output is correct |
17 |
Correct |
1 ms |
4956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Correct |
1 ms |
4956 KB |
Output is correct |
3 |
Correct |
1 ms |
4956 KB |
Output is correct |
4 |
Correct |
1 ms |
5036 KB |
Output is correct |
5 |
Correct |
1 ms |
4956 KB |
Output is correct |
6 |
Correct |
1 ms |
4956 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
8 |
Correct |
1 ms |
4956 KB |
Output is correct |
9 |
Correct |
1 ms |
4956 KB |
Output is correct |
10 |
Correct |
1 ms |
4956 KB |
Output is correct |
11 |
Correct |
1 ms |
4956 KB |
Output is correct |
12 |
Correct |
1 ms |
4956 KB |
Output is correct |
13 |
Correct |
1 ms |
4956 KB |
Output is correct |
14 |
Correct |
1 ms |
4956 KB |
Output is correct |
15 |
Correct |
1 ms |
4956 KB |
Output is correct |
16 |
Correct |
1 ms |
4956 KB |
Output is correct |
17 |
Correct |
1 ms |
4956 KB |
Output is correct |
18 |
Correct |
1 ms |
4956 KB |
Output is correct |
19 |
Correct |
1 ms |
4956 KB |
Output is correct |
20 |
Correct |
1 ms |
4956 KB |
Output is correct |
21 |
Correct |
1 ms |
4956 KB |
Output is correct |
22 |
Correct |
1 ms |
4956 KB |
Output is correct |
23 |
Correct |
1 ms |
4952 KB |
Output is correct |
24 |
Correct |
1 ms |
4956 KB |
Output is correct |
25 |
Correct |
1 ms |
4956 KB |
Output is correct |
26 |
Correct |
1 ms |
4956 KB |
Output is correct |
27 |
Correct |
1 ms |
4956 KB |
Output is correct |
28 |
Correct |
1 ms |
4956 KB |
Output is correct |
29 |
Correct |
1 ms |
4956 KB |
Output is correct |
30 |
Correct |
1 ms |
4956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Correct |
1 ms |
4956 KB |
Output is correct |
3 |
Correct |
1 ms |
4956 KB |
Output is correct |
4 |
Correct |
1 ms |
4956 KB |
Output is correct |
5 |
Correct |
1 ms |
4956 KB |
Output is correct |
6 |
Correct |
1 ms |
4956 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
8 |
Correct |
1 ms |
4956 KB |
Output is correct |
9 |
Correct |
1 ms |
4956 KB |
Output is correct |
10 |
Correct |
1 ms |
4956 KB |
Output is correct |
11 |
Correct |
1 ms |
4956 KB |
Output is correct |
12 |
Correct |
1 ms |
4956 KB |
Output is correct |
13 |
Correct |
1 ms |
4956 KB |
Output is correct |
14 |
Correct |
1 ms |
4956 KB |
Output is correct |
15 |
Correct |
1 ms |
4956 KB |
Output is correct |
16 |
Correct |
1 ms |
4956 KB |
Output is correct |
17 |
Correct |
1 ms |
4956 KB |
Output is correct |
18 |
Correct |
1 ms |
4952 KB |
Output is correct |
19 |
Correct |
1 ms |
4956 KB |
Output is correct |
20 |
Correct |
1 ms |
4956 KB |
Output is correct |
21 |
Correct |
1 ms |
5036 KB |
Output is correct |
22 |
Correct |
1 ms |
4956 KB |
Output is correct |
23 |
Correct |
1 ms |
4956 KB |
Output is correct |
24 |
Correct |
1 ms |
4956 KB |
Output is correct |
25 |
Correct |
1 ms |
4956 KB |
Output is correct |
26 |
Correct |
1 ms |
4956 KB |
Output is correct |
27 |
Correct |
1 ms |
4956 KB |
Output is correct |
28 |
Correct |
1 ms |
4956 KB |
Output is correct |
29 |
Correct |
1 ms |
4956 KB |
Output is correct |
30 |
Correct |
1 ms |
4956 KB |
Output is correct |
31 |
Correct |
1 ms |
4956 KB |
Output is correct |
32 |
Correct |
1 ms |
4956 KB |
Output is correct |
33 |
Correct |
1 ms |
4956 KB |
Output is correct |
34 |
Correct |
1 ms |
4956 KB |
Output is correct |
35 |
Correct |
1 ms |
4956 KB |
Output is correct |
36 |
Correct |
1 ms |
4956 KB |
Output is correct |
37 |
Correct |
1 ms |
4956 KB |
Output is correct |
38 |
Correct |
1 ms |
4956 KB |
Output is correct |
39 |
Correct |
1 ms |
4956 KB |
Output is correct |
40 |
Correct |
1 ms |
4952 KB |
Output is correct |
41 |
Correct |
1 ms |
4956 KB |
Output is correct |
42 |
Correct |
1 ms |
4956 KB |
Output is correct |
43 |
Correct |
1 ms |
4956 KB |
Output is correct |
44 |
Correct |
1 ms |
4956 KB |
Output is correct |
45 |
Correct |
1 ms |
4956 KB |
Output is correct |
46 |
Correct |
1 ms |
4956 KB |
Output is correct |
47 |
Correct |
1 ms |
4956 KB |
Output is correct |
48 |
Correct |
27 ms |
10456 KB |
Output is correct |
49 |
Correct |
30 ms |
10960 KB |
Output is correct |
50 |
Correct |
31 ms |
10956 KB |
Output is correct |
51 |
Correct |
22 ms |
9680 KB |
Output is correct |
52 |
Correct |
30 ms |
10956 KB |
Output is correct |
53 |
Correct |
27 ms |
10192 KB |
Output is correct |
54 |
Correct |
22 ms |
11224 KB |
Output is correct |
55 |
Correct |
33 ms |
17864 KB |
Output is correct |
56 |
Correct |
31 ms |
14276 KB |
Output is correct |
57 |
Correct |
37 ms |
13000 KB |
Output is correct |
58 |
Correct |
32 ms |
11984 KB |
Output is correct |
59 |
Correct |
30 ms |
10956 KB |
Output is correct |
60 |
Correct |
26 ms |
11116 KB |
Output is correct |
61 |
Correct |
25 ms |
10948 KB |
Output is correct |
62 |
Correct |
25 ms |
11268 KB |
Output is correct |
63 |
Correct |
25 ms |
10960 KB |
Output is correct |
64 |
Correct |
27 ms |
11204 KB |
Output is correct |
65 |
Correct |
31 ms |
11360 KB |
Output is correct |
66 |
Correct |
28 ms |
10960 KB |
Output is correct |
67 |
Correct |
18 ms |
9764 KB |
Output is correct |
68 |
Correct |
22 ms |
10444 KB |
Output is correct |
69 |
Correct |
34 ms |
11472 KB |
Output is correct |
70 |
Correct |
23 ms |
10948 KB |
Output is correct |
71 |
Correct |
19 ms |
9420 KB |
Output is correct |
72 |
Correct |
22 ms |
10192 KB |
Output is correct |
73 |
Correct |
55 ms |
11472 KB |
Output is correct |
74 |
Correct |
26 ms |
10948 KB |
Output is correct |
75 |
Correct |
35 ms |
11476 KB |
Output is correct |
76 |
Correct |
30 ms |
10692 KB |
Output is correct |
77 |
Correct |
42 ms |
11204 KB |
Output is correct |
78 |
Correct |
19 ms |
9164 KB |
Output is correct |
79 |
Correct |
23 ms |
9680 KB |
Output is correct |
80 |
Correct |
32 ms |
11472 KB |
Output is correct |
81 |
Correct |
39 ms |
11476 KB |
Output is correct |
82 |
Correct |
51 ms |
10956 KB |
Output is correct |