Submission #711375

# Submission time Handle Problem Language Result Execution time Memory
711375 2023-03-16T18:24:28 Z sysia Village (BOI20_village) C++17
50 / 100
76 ms 19032 KB
//Sylwia Sapkowska
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;

void __print(int x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define int long long
typedef pair<int, int> T;
const int oo = 1e18, oo2 = 1e9+7, K = 30;
const int mod = 998244353;

void solve(){
    int n; cin >> n;
    vector<vector<int>>g(n+1);
    for (int i = 1; i<n; i++){
        int a, b; cin >> a >> b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    int ans = 0;
    vector<int>mn(n+1);
    iota(mn.begin(), mn.end(), 0);
    function<void(int, int)>dfs = [&](int v, int pa){
        for (auto x: g[v]){
            if (x == pa) continue;
            dfs(x, v);
        }
        if (mn[v] == v) {
            swap(mn[v], mn[pa]);
            ans+=2;
        }
    };
    dfs(1, 1);
    if (mn[1] == 1) {
        swap(mn[1], mn[g[1][0]]);
    }
    for (int i = 1; i<=n; i++){
        if (mn[i] == i){
            assert(false);
        }
    }
    cout << ans << " " << 2137 << "\n";
    for (int i = 1; i<=n; i++) cout << mn[i] << " ";
    cout << "\n";
    for (int i = 1; i<=n; i++) cout << 1 << " ";
    cout << "\n";
}

int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 212 KB Partially correct
2 Partially correct 1 ms 212 KB Partially correct
3 Partially correct 1 ms 212 KB Partially correct
4 Partially correct 0 ms 212 KB Partially correct
5 Partially correct 1 ms 320 KB Partially correct
6 Partially correct 1 ms 320 KB Partially correct
7 Partially correct 0 ms 212 KB Partially correct
8 Partially correct 0 ms 212 KB Partially correct
9 Partially correct 1 ms 324 KB Partially correct
10 Partially correct 1 ms 212 KB Partially correct
11 Partially correct 1 ms 212 KB Partially correct
12 Partially correct 1 ms 212 KB Partially correct
13 Partially correct 1 ms 316 KB Partially correct
14 Partially correct 1 ms 212 KB Partially correct
15 Partially correct 1 ms 324 KB Partially correct
16 Partially correct 1 ms 212 KB Partially correct
17 Partially correct 1 ms 212 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 212 KB Partially correct
2 Partially correct 1 ms 340 KB Partially correct
3 Partially correct 1 ms 340 KB Partially correct
4 Partially correct 1 ms 324 KB Partially correct
5 Partially correct 1 ms 340 KB Partially correct
6 Partially correct 1 ms 328 KB Partially correct
7 Partially correct 1 ms 452 KB Partially correct
8 Partially correct 1 ms 340 KB Partially correct
9 Partially correct 1 ms 340 KB Partially correct
10 Partially correct 1 ms 340 KB Partially correct
11 Partially correct 1 ms 340 KB Partially correct
12 Partially correct 1 ms 340 KB Partially correct
13 Partially correct 1 ms 340 KB Partially correct
14 Partially correct 1 ms 340 KB Partially correct
15 Partially correct 1 ms 340 KB Partially correct
16 Partially correct 1 ms 328 KB Partially correct
17 Partially correct 1 ms 324 KB Partially correct
18 Partially correct 1 ms 340 KB Partially correct
19 Partially correct 1 ms 340 KB Partially correct
20 Partially correct 1 ms 340 KB Partially correct
21 Partially correct 1 ms 432 KB Partially correct
22 Partially correct 1 ms 320 KB Partially correct
23 Partially correct 1 ms 340 KB Partially correct
24 Partially correct 1 ms 340 KB Partially correct
25 Partially correct 1 ms 340 KB Partially correct
26 Partially correct 1 ms 340 KB Partially correct
27 Partially correct 1 ms 340 KB Partially correct
28 Partially correct 1 ms 340 KB Partially correct
29 Partially correct 1 ms 340 KB Partially correct
30 Partially correct 1 ms 340 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 212 KB Partially correct
2 Partially correct 1 ms 212 KB Partially correct
3 Partially correct 1 ms 212 KB Partially correct
4 Partially correct 0 ms 212 KB Partially correct
5 Partially correct 1 ms 320 KB Partially correct
6 Partially correct 1 ms 320 KB Partially correct
7 Partially correct 0 ms 212 KB Partially correct
8 Partially correct 0 ms 212 KB Partially correct
9 Partially correct 1 ms 324 KB Partially correct
10 Partially correct 1 ms 212 KB Partially correct
11 Partially correct 1 ms 212 KB Partially correct
12 Partially correct 1 ms 212 KB Partially correct
13 Partially correct 1 ms 316 KB Partially correct
14 Partially correct 1 ms 212 KB Partially correct
15 Partially correct 1 ms 324 KB Partially correct
16 Partially correct 1 ms 212 KB Partially correct
17 Partially correct 1 ms 212 KB Partially correct
18 Partially correct 0 ms 212 KB Partially correct
19 Partially correct 1 ms 340 KB Partially correct
20 Partially correct 1 ms 340 KB Partially correct
21 Partially correct 1 ms 324 KB Partially correct
22 Partially correct 1 ms 340 KB Partially correct
23 Partially correct 1 ms 328 KB Partially correct
24 Partially correct 1 ms 452 KB Partially correct
25 Partially correct 1 ms 340 KB Partially correct
26 Partially correct 1 ms 340 KB Partially correct
27 Partially correct 1 ms 340 KB Partially correct
28 Partially correct 1 ms 340 KB Partially correct
29 Partially correct 1 ms 340 KB Partially correct
30 Partially correct 1 ms 340 KB Partially correct
31 Partially correct 1 ms 340 KB Partially correct
32 Partially correct 1 ms 340 KB Partially correct
33 Partially correct 1 ms 328 KB Partially correct
34 Partially correct 1 ms 324 KB Partially correct
35 Partially correct 1 ms 340 KB Partially correct
36 Partially correct 1 ms 340 KB Partially correct
37 Partially correct 1 ms 340 KB Partially correct
38 Partially correct 1 ms 432 KB Partially correct
39 Partially correct 1 ms 320 KB Partially correct
40 Partially correct 1 ms 340 KB Partially correct
41 Partially correct 1 ms 340 KB Partially correct
42 Partially correct 1 ms 340 KB Partially correct
43 Partially correct 1 ms 340 KB Partially correct
44 Partially correct 1 ms 340 KB Partially correct
45 Partially correct 1 ms 340 KB Partially correct
46 Partially correct 1 ms 340 KB Partially correct
47 Partially correct 1 ms 340 KB Partially correct
48 Partially correct 49 ms 8356 KB Partially correct
49 Partially correct 53 ms 9140 KB Partially correct
50 Partially correct 64 ms 9144 KB Partially correct
51 Partially correct 39 ms 7116 KB Partially correct
52 Partially correct 52 ms 9008 KB Partially correct
53 Partially correct 69 ms 8088 KB Partially correct
54 Partially correct 25 ms 9296 KB Partially correct
55 Partially correct 76 ms 19032 KB Partially correct
56 Partially correct 66 ms 14004 KB Partially correct
57 Partially correct 53 ms 12320 KB Partially correct
58 Partially correct 67 ms 10764 KB Partially correct
59 Partially correct 67 ms 9340 KB Partially correct
60 Partially correct 49 ms 9204 KB Partially correct
61 Partially correct 39 ms 9276 KB Partially correct
62 Partially correct 54 ms 9476 KB Partially correct
63 Partially correct 45 ms 8864 KB Partially correct
64 Partially correct 46 ms 9476 KB Partially correct
65 Partially correct 61 ms 9560 KB Partially correct
66 Partially correct 42 ms 8908 KB Partially correct
67 Partially correct 31 ms 6920 KB Partially correct
68 Partially correct 42 ms 8140 KB Partially correct
69 Partially correct 49 ms 9664 KB Partially correct
70 Partially correct 66 ms 9056 KB Partially correct
71 Partially correct 39 ms 6764 KB Partially correct
72 Partially correct 36 ms 7628 KB Partially correct
73 Partially correct 48 ms 9676 KB Partially correct
74 Partially correct 49 ms 8780 KB Partially correct
75 Partially correct 53 ms 9740 KB Partially correct
76 Partially correct 54 ms 8956 KB Partially correct
77 Partially correct 66 ms 9320 KB Partially correct
78 Partially correct 30 ms 6348 KB Partially correct
79 Partially correct 35 ms 7212 KB Partially correct
80 Partially correct 57 ms 9536 KB Partially correct
81 Partially correct 47 ms 9476 KB Partially correct
82 Partially correct 49 ms 9292 KB Partially correct