답안 #857936

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
857936 2023-10-07T07:33:22 Z Trisanu_Das Village (BOI20_village) C++17
25 / 100
700 ms 13540 KB
#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e5 + 1;
vector<int> adj[maxn];
int deg[maxn], pos[maxn];
 
int main() {
    int n; cin >> n;
    int a, b;
    for (int i = 0; i < n - 1; i++) {
        cin >> a >> b;
        --a, --b;
        adj[a].push_back(b);
        adj[b].push_back(a);
        ++deg[a], ++deg[b];
        pos[i] = i;
    }
    pos[n - 1] = n - 1;
    unordered_set<int> leafs;
    for (int i = 0; i < n; i++) if (deg[i] == 1) leafs.insert(i);
    int sol = 0;
    while (!leafs.empty()) {
        int cur = *leafs.begin();
        leafs.erase(leafs.begin());
        int next = adj[cur][0];
        if (pos[cur] == cur) {
            sol += 2;
            swap(pos[cur], pos[next]);
        }
        if (--deg[next] == 1) leafs.insert(adj[cur][0]);
        adj[next].erase(find(adj[next].begin(), adj[next].end(), cur));
    }
    cout << sol << ' ' << 1 << '\n';
    vector<int> loc(n);
    for (int i = 0; i < n; i++) {
        loc[pos[i]] = i;
        assert(pos[i] != i);
    }
    for (int i = 0; i < n; i++) cout << loc[i] + 1 << ' ';
    cout << '\n';
    for (int i = 0; i < n; i++) cout << 1 << ' ';
    cout << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 3164 KB Partially correct
2 Partially correct 1 ms 3164 KB Partially correct
3 Partially correct 1 ms 3164 KB Partially correct
4 Partially correct 1 ms 3164 KB Partially correct
5 Partially correct 1 ms 3164 KB Partially correct
6 Partially correct 1 ms 3164 KB Partially correct
7 Partially correct 1 ms 3164 KB Partially correct
8 Partially correct 1 ms 3164 KB Partially correct
9 Partially correct 1 ms 3164 KB Partially correct
10 Partially correct 1 ms 3164 KB Partially correct
11 Partially correct 1 ms 3164 KB Partially correct
12 Partially correct 1 ms 3160 KB Partially correct
13 Partially correct 1 ms 3164 KB Partially correct
14 Partially correct 1 ms 3164 KB Partially correct
15 Partially correct 1 ms 3164 KB Partially correct
16 Partially correct 1 ms 3164 KB Partially correct
17 Partially correct 1 ms 3164 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 3164 KB Partially correct
2 Partially correct 1 ms 3420 KB Partially correct
3 Partially correct 1 ms 3420 KB Partially correct
4 Partially correct 2 ms 3572 KB Partially correct
5 Partially correct 1 ms 3420 KB Partially correct
6 Partially correct 2 ms 3420 KB Partially correct
7 Partially correct 2 ms 3420 KB Partially correct
8 Partially correct 2 ms 3420 KB Partially correct
9 Partially correct 1 ms 3420 KB Partially correct
10 Partially correct 2 ms 3416 KB Partially correct
11 Partially correct 2 ms 3420 KB Partially correct
12 Partially correct 2 ms 3400 KB Partially correct
13 Partially correct 2 ms 3420 KB Partially correct
14 Partially correct 2 ms 3420 KB Partially correct
15 Partially correct 1 ms 3420 KB Partially correct
16 Partially correct 2 ms 3420 KB Partially correct
17 Partially correct 2 ms 3420 KB Partially correct
18 Partially correct 2 ms 3420 KB Partially correct
19 Partially correct 2 ms 3420 KB Partially correct
20 Partially correct 2 ms 3420 KB Partially correct
21 Partially correct 2 ms 3420 KB Partially correct
22 Partially correct 2 ms 3252 KB Partially correct
23 Partially correct 2 ms 3416 KB Partially correct
24 Partially correct 2 ms 3420 KB Partially correct
25 Partially correct 1 ms 3416 KB Partially correct
26 Partially correct 2 ms 3616 KB Partially correct
27 Partially correct 2 ms 3420 KB Partially correct
28 Partially correct 1 ms 3420 KB Partially correct
29 Partially correct 2 ms 3420 KB Partially correct
30 Partially correct 1 ms 3420 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 3164 KB Partially correct
2 Partially correct 1 ms 3164 KB Partially correct
3 Partially correct 1 ms 3164 KB Partially correct
4 Partially correct 1 ms 3164 KB Partially correct
5 Partially correct 1 ms 3164 KB Partially correct
6 Partially correct 1 ms 3164 KB Partially correct
7 Partially correct 1 ms 3164 KB Partially correct
8 Partially correct 1 ms 3164 KB Partially correct
9 Partially correct 1 ms 3164 KB Partially correct
10 Partially correct 1 ms 3164 KB Partially correct
11 Partially correct 1 ms 3164 KB Partially correct
12 Partially correct 1 ms 3160 KB Partially correct
13 Partially correct 1 ms 3164 KB Partially correct
14 Partially correct 1 ms 3164 KB Partially correct
15 Partially correct 1 ms 3164 KB Partially correct
16 Partially correct 1 ms 3164 KB Partially correct
17 Partially correct 1 ms 3164 KB Partially correct
18 Partially correct 1 ms 3164 KB Partially correct
19 Partially correct 1 ms 3420 KB Partially correct
20 Partially correct 1 ms 3420 KB Partially correct
21 Partially correct 2 ms 3572 KB Partially correct
22 Partially correct 1 ms 3420 KB Partially correct
23 Partially correct 2 ms 3420 KB Partially correct
24 Partially correct 2 ms 3420 KB Partially correct
25 Partially correct 2 ms 3420 KB Partially correct
26 Partially correct 1 ms 3420 KB Partially correct
27 Partially correct 2 ms 3416 KB Partially correct
28 Partially correct 2 ms 3420 KB Partially correct
29 Partially correct 2 ms 3400 KB Partially correct
30 Partially correct 2 ms 3420 KB Partially correct
31 Partially correct 2 ms 3420 KB Partially correct
32 Partially correct 1 ms 3420 KB Partially correct
33 Partially correct 2 ms 3420 KB Partially correct
34 Partially correct 2 ms 3420 KB Partially correct
35 Partially correct 2 ms 3420 KB Partially correct
36 Partially correct 2 ms 3420 KB Partially correct
37 Partially correct 2 ms 3420 KB Partially correct
38 Partially correct 2 ms 3420 KB Partially correct
39 Partially correct 2 ms 3252 KB Partially correct
40 Partially correct 2 ms 3416 KB Partially correct
41 Partially correct 2 ms 3420 KB Partially correct
42 Partially correct 1 ms 3416 KB Partially correct
43 Partially correct 2 ms 3616 KB Partially correct
44 Partially correct 2 ms 3420 KB Partially correct
45 Partially correct 1 ms 3420 KB Partially correct
46 Partially correct 2 ms 3420 KB Partially correct
47 Partially correct 1 ms 3420 KB Partially correct
48 Partially correct 79 ms 10660 KB Partially correct
49 Partially correct 75 ms 11036 KB Partially correct
50 Partially correct 74 ms 11108 KB Partially correct
51 Partially correct 57 ms 9568 KB Partially correct
52 Partially correct 72 ms 10936 KB Partially correct
53 Partially correct 65 ms 10200 KB Partially correct
54 Partially correct 33 ms 6148 KB Partially correct
55 Partially correct 66 ms 8784 KB Partially correct
56 Partially correct 74 ms 10284 KB Partially correct
57 Partially correct 71 ms 9904 KB Partially correct
58 Partially correct 71 ms 9940 KB Partially correct
59 Partially correct 72 ms 11104 KB Partially correct
60 Execution timed out 875 ms 13540 KB Time limit exceeded
61 Halted 0 ms 0 KB -