Submission #418826

# Submission time Handle Problem Language Result Execution time Memory
418826 2021-06-06T01:07:04 Z ly20 Village (BOI20_village) C++17
50 / 100
106 ms 10616 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 112345;
vector <int> grafo[MAXN];
long long mn, mx;
int rmn[MAXN], rmx[MAXN];
int cur[MAXN];
int grau[MAXN];
int marc[MAXN];
int main() {
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n - 1; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        grafo[a].push_back(b);
        grafo[b].push_back(a);
        grau[a]++; grau[b]++;
    }
    queue <int> fila;
    for(int i = 1; i <= n; i++) {
            rmn[i] = i;
        if(grau[i] == 1) fila.push(i);
    }
    while(!fila.empty()) {
        int cur = fila.front(); fila.pop();
        marc[cur] = 1;
        int p = grafo[cur][0];
        for(int i = 0 ;i < grafo[cur].size(); i++) {
            int viz = grafo[cur][i];
            grau[viz]--;
            if(grau[viz] == 1) fila.push(viz);
            if(marc[viz] == 0) p = viz;
        }
        if(rmn[cur] == cur) {
            swap(rmn[cur], rmn[p]);
            mn += 2;
        }
    }
    printf("%lld %lld\n", mn, mn);
    for(int i = 1; i <= n; i++) {
        printf("%d ", rmn[i]);
    }
    printf("\n");
    for(int i = 1; i <= n; i++) {
        printf("%d ", rmn[i]);
    }
    printf("\n");
    return 0;
}

Compilation message

Village.cpp: In function 'int main()':
Village.cpp:29:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for(int i = 0 ;i < grafo[cur].size(); i++) {
      |                        ~~^~~~~~~~~~~~~~~~~~~
Village.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
Village.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d %d", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 2892 KB Partially correct
2 Partially correct 2 ms 2892 KB Partially correct
3 Correct 3 ms 2832 KB Output is correct
4 Partially correct 2 ms 2892 KB Partially correct
5 Partially correct 2 ms 2892 KB Partially correct
6 Partially correct 2 ms 2892 KB Partially correct
7 Correct 2 ms 2892 KB Output is correct
8 Partially correct 2 ms 2892 KB Partially correct
9 Partially correct 2 ms 2892 KB Partially correct
10 Partially correct 2 ms 2892 KB Partially correct
11 Partially correct 2 ms 2892 KB Partially correct
12 Partially correct 2 ms 2892 KB Partially correct
13 Partially correct 2 ms 2892 KB Partially correct
14 Correct 2 ms 2892 KB Output is correct
15 Partially correct 2 ms 2892 KB Partially correct
16 Partially correct 2 ms 2892 KB Partially correct
17 Partially correct 2 ms 2892 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 2892 KB Partially correct
2 Partially correct 2 ms 2892 KB Partially correct
3 Partially correct 2 ms 2892 KB Partially correct
4 Partially correct 3 ms 2892 KB Partially correct
5 Partially correct 3 ms 2892 KB Partially correct
6 Partially correct 2 ms 2892 KB Partially correct
7 Partially correct 3 ms 2892 KB Partially correct
8 Partially correct 3 ms 2892 KB Partially correct
9 Partially correct 3 ms 2892 KB Partially correct
10 Partially correct 3 ms 2892 KB Partially correct
11 Partially correct 4 ms 2892 KB Partially correct
12 Correct 3 ms 2892 KB Output is correct
13 Partially correct 2 ms 2948 KB Partially correct
14 Partially correct 2 ms 3020 KB Partially correct
15 Partially correct 2 ms 2892 KB Partially correct
16 Partially correct 3 ms 2952 KB Partially correct
17 Partially correct 3 ms 3020 KB Partially correct
18 Partially correct 3 ms 3020 KB Partially correct
19 Partially correct 3 ms 3020 KB Partially correct
20 Partially correct 3 ms 2952 KB Partially correct
21 Partially correct 3 ms 2892 KB Partially correct
22 Partially correct 2 ms 2952 KB Partially correct
23 Partially correct 4 ms 2892 KB Partially correct
24 Partially correct 3 ms 2892 KB Partially correct
25 Partially correct 2 ms 2900 KB Partially correct
26 Partially correct 3 ms 2892 KB Partially correct
27 Partially correct 3 ms 2892 KB Partially correct
28 Partially correct 3 ms 3020 KB Partially correct
29 Partially correct 3 ms 3020 KB Partially correct
30 Partially correct 3 ms 2892 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 2892 KB Partially correct
2 Partially correct 2 ms 2892 KB Partially correct
3 Correct 3 ms 2832 KB Output is correct
4 Partially correct 2 ms 2892 KB Partially correct
5 Partially correct 2 ms 2892 KB Partially correct
6 Partially correct 2 ms 2892 KB Partially correct
7 Correct 2 ms 2892 KB Output is correct
8 Partially correct 2 ms 2892 KB Partially correct
9 Partially correct 2 ms 2892 KB Partially correct
10 Partially correct 2 ms 2892 KB Partially correct
11 Partially correct 2 ms 2892 KB Partially correct
12 Partially correct 2 ms 2892 KB Partially correct
13 Partially correct 2 ms 2892 KB Partially correct
14 Correct 2 ms 2892 KB Output is correct
15 Partially correct 2 ms 2892 KB Partially correct
16 Partially correct 2 ms 2892 KB Partially correct
17 Partially correct 2 ms 2892 KB Partially correct
18 Partially correct 2 ms 2892 KB Partially correct
19 Partially correct 2 ms 2892 KB Partially correct
20 Partially correct 2 ms 2892 KB Partially correct
21 Partially correct 3 ms 2892 KB Partially correct
22 Partially correct 3 ms 2892 KB Partially correct
23 Partially correct 2 ms 2892 KB Partially correct
24 Partially correct 3 ms 2892 KB Partially correct
25 Partially correct 3 ms 2892 KB Partially correct
26 Partially correct 3 ms 2892 KB Partially correct
27 Partially correct 3 ms 2892 KB Partially correct
28 Partially correct 4 ms 2892 KB Partially correct
29 Correct 3 ms 2892 KB Output is correct
30 Partially correct 2 ms 2948 KB Partially correct
31 Partially correct 2 ms 3020 KB Partially correct
32 Partially correct 2 ms 2892 KB Partially correct
33 Partially correct 3 ms 2952 KB Partially correct
34 Partially correct 3 ms 3020 KB Partially correct
35 Partially correct 3 ms 3020 KB Partially correct
36 Partially correct 3 ms 3020 KB Partially correct
37 Partially correct 3 ms 2952 KB Partially correct
38 Partially correct 3 ms 2892 KB Partially correct
39 Partially correct 2 ms 2952 KB Partially correct
40 Partially correct 4 ms 2892 KB Partially correct
41 Partially correct 3 ms 2892 KB Partially correct
42 Partially correct 2 ms 2900 KB Partially correct
43 Partially correct 3 ms 2892 KB Partially correct
44 Partially correct 3 ms 2892 KB Partially correct
45 Partially correct 3 ms 3020 KB Partially correct
46 Partially correct 3 ms 3020 KB Partially correct
47 Partially correct 3 ms 2892 KB Partially correct
48 Partially correct 80 ms 9228 KB Partially correct
49 Partially correct 102 ms 9892 KB Partially correct
50 Partially correct 80 ms 9828 KB Partially correct
51 Partially correct 60 ms 8260 KB Partially correct
52 Partially correct 94 ms 9972 KB Partially correct
53 Partially correct 76 ms 9156 KB Partially correct
54 Partially correct 51 ms 6220 KB Partially correct
55 Partially correct 106 ms 9604 KB Partially correct
56 Partially correct 98 ms 9648 KB Partially correct
57 Partially correct 82 ms 9520 KB Partially correct
58 Partially correct 80 ms 9652 KB Partially correct
59 Partially correct 79 ms 9924 KB Partially correct
60 Correct 67 ms 10236 KB Output is correct
61 Partially correct 72 ms 10432 KB Partially correct
62 Partially correct 75 ms 10468 KB Partially correct
63 Partially correct 92 ms 9984 KB Partially correct
64 Partially correct 78 ms 10372 KB Partially correct
65 Partially correct 88 ms 10616 KB Partially correct
66 Partially correct 68 ms 10044 KB Partially correct
67 Partially correct 54 ms 8448 KB Partially correct
68 Partially correct 61 ms 9260 KB Partially correct
69 Partially correct 73 ms 10564 KB Partially correct
70 Partially correct 95 ms 10052 KB Partially correct
71 Partially correct 50 ms 8228 KB Partially correct
72 Partially correct 63 ms 8820 KB Partially correct
73 Partially correct 74 ms 10544 KB Partially correct
74 Partially correct 69 ms 9892 KB Partially correct
75 Partially correct 101 ms 9668 KB Partially correct
76 Partially correct 90 ms 9812 KB Partially correct
77 Partially correct 75 ms 10052 KB Partially correct
78 Partially correct 54 ms 7680 KB Partially correct
79 Partially correct 70 ms 8472 KB Partially correct
80 Partially correct 86 ms 9668 KB Partially correct
81 Partially correct 74 ms 10236 KB Partially correct
82 Partially correct 73 ms 10236 KB Partially correct