# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
896149 |
2023-12-31T22:27:32 Z |
ShaShi |
Village (BOI20_village) |
C++17 |
|
44 ms |
14904 KB |
#include <bits/stdc++.h>
// #define int long long
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define kill(x) cout << x << endl, exit(0);
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAXN = (int)1e5 + 7;
const int MOD = 998244353;
const int INF = (int)1e9 + 7;
int n, m, t, flag, k, u, v, w, ans, ans2, tmp, tmp2, tmp3, tmp4;
int arr[MAXN], arr2[MAXN], par[MAXN], h[MAXN];
vector<int> adj[MAXN];
int DFS(int v, int p=-1) {
int res = 0;
for (int u:adj[v]) {
if (u == p) continue;
res += DFS(u, v);
}
if (res) return 0;
if (v != 1) {
swap(arr[v], arr[p]);
ans++;
return 1;
}
swap(arr[1], arr[adj[1][0]]);
ans++;
return 0;
}
int32_t main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
for (int i=1; i<n; i++) {
cin >> u >> v;
adj[u].pb(v);
adj[v].pb(u);
}
// Min
for (int i=1; i<=n; i++) arr[i] = i;
DFS(1);
for (int i=1; i<=n; i++) arr2[arr[i]] = i;
cout << 2*ans << " " << ans << endl;
for (int i=1; i<=n; i++) cout << arr2[i] << " ";
cout << endl;
for (int i=1; i<=n; i++) cout << arr2[i] << " ";
cout << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
2648 KB |
Partially correct |
2 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
3 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
4 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
5 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
6 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
7 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
8 |
Partially correct |
1 ms |
2724 KB |
Partially correct |
9 |
Partially correct |
1 ms |
2648 KB |
Partially correct |
10 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
11 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
12 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
13 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
14 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
15 |
Partially correct |
1 ms |
2904 KB |
Partially correct |
16 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
17 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
2 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
3 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
4 |
Partially correct |
1 ms |
2648 KB |
Partially correct |
5 |
Partially correct |
1 ms |
2812 KB |
Partially correct |
6 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
7 |
Partially correct |
1 ms |
2908 KB |
Partially correct |
8 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
9 |
Partially correct |
1 ms |
2648 KB |
Partially correct |
10 |
Partially correct |
2 ms |
2908 KB |
Partially correct |
11 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
12 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
13 |
Partially correct |
1 ms |
2648 KB |
Partially correct |
14 |
Partially correct |
1 ms |
2648 KB |
Partially correct |
15 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
16 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
17 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
18 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
19 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
20 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
21 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
22 |
Partially correct |
2 ms |
2652 KB |
Partially correct |
23 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
24 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
25 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
26 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
27 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
28 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
29 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
30 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
2648 KB |
Partially correct |
2 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
3 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
4 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
5 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
6 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
7 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
8 |
Partially correct |
1 ms |
2724 KB |
Partially correct |
9 |
Partially correct |
1 ms |
2648 KB |
Partially correct |
10 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
11 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
12 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
13 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
14 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
15 |
Partially correct |
1 ms |
2904 KB |
Partially correct |
16 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
17 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
18 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
19 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
20 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
21 |
Partially correct |
1 ms |
2648 KB |
Partially correct |
22 |
Partially correct |
1 ms |
2812 KB |
Partially correct |
23 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
24 |
Partially correct |
1 ms |
2908 KB |
Partially correct |
25 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
26 |
Partially correct |
1 ms |
2648 KB |
Partially correct |
27 |
Partially correct |
2 ms |
2908 KB |
Partially correct |
28 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
29 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
30 |
Partially correct |
1 ms |
2648 KB |
Partially correct |
31 |
Partially correct |
1 ms |
2648 KB |
Partially correct |
32 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
33 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
34 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
35 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
36 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
37 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
38 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
39 |
Partially correct |
2 ms |
2652 KB |
Partially correct |
40 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
41 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
42 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
43 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
44 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
45 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
46 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
47 |
Partially correct |
1 ms |
2652 KB |
Partially correct |
48 |
Partially correct |
32 ms |
8484 KB |
Partially correct |
49 |
Partially correct |
35 ms |
9040 KB |
Partially correct |
50 |
Partially correct |
36 ms |
9040 KB |
Partially correct |
51 |
Partially correct |
27 ms |
7760 KB |
Partially correct |
52 |
Partially correct |
38 ms |
8916 KB |
Partially correct |
53 |
Partially correct |
32 ms |
8464 KB |
Partially correct |
54 |
Partially correct |
19 ms |
8536 KB |
Partially correct |
55 |
Partially correct |
42 ms |
14904 KB |
Partially correct |
56 |
Partially correct |
38 ms |
11860 KB |
Partially correct |
57 |
Partially correct |
38 ms |
10900 KB |
Partially correct |
58 |
Partially correct |
40 ms |
10072 KB |
Partially correct |
59 |
Partially correct |
35 ms |
9044 KB |
Partially correct |
60 |
Partially correct |
33 ms |
9380 KB |
Partially correct |
61 |
Partially correct |
32 ms |
9300 KB |
Partially correct |
62 |
Partially correct |
36 ms |
9560 KB |
Partially correct |
63 |
Partially correct |
30 ms |
9052 KB |
Partially correct |
64 |
Partially correct |
33 ms |
9308 KB |
Partially correct |
65 |
Partially correct |
36 ms |
9552 KB |
Partially correct |
66 |
Partially correct |
28 ms |
9040 KB |
Partially correct |
67 |
Partially correct |
23 ms |
7772 KB |
Partially correct |
68 |
Partially correct |
28 ms |
8308 KB |
Partially correct |
69 |
Partially correct |
31 ms |
9560 KB |
Partially correct |
70 |
Partially correct |
28 ms |
9296 KB |
Partially correct |
71 |
Partially correct |
28 ms |
7428 KB |
Partially correct |
72 |
Partially correct |
24 ms |
8028 KB |
Partially correct |
73 |
Partially correct |
30 ms |
9592 KB |
Partially correct |
74 |
Partially correct |
31 ms |
8880 KB |
Partially correct |
75 |
Partially correct |
35 ms |
9052 KB |
Partially correct |
76 |
Partially correct |
44 ms |
9040 KB |
Partially correct |
77 |
Partially correct |
31 ms |
9156 KB |
Partially correct |
78 |
Partially correct |
23 ms |
6996 KB |
Partially correct |
79 |
Partially correct |
28 ms |
7692 KB |
Partially correct |
80 |
Partially correct |
37 ms |
8788 KB |
Partially correct |
81 |
Partially correct |
32 ms |
9184 KB |
Partially correct |
82 |
Partially correct |
30 ms |
9308 KB |
Partially correct |