QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#829780 | #9911. 路南柯 | hhoppitree# | 0 | 11ms | 3800kb | C++14 | 1.0kb | 2024-12-24 13:17:21 | 2024-12-24 13:17:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
vector<int> G[N];
int deg[N];
signed main() {
int T; scanf("%d", &T);
while (T--) {
int n; scanf("%d", &n);
for (int i = 1; i <= n; ++i) G[i].clear();
for (int i = 1, x, y; i < n; ++i) {
scanf("%d%d", &x, &y), G[x].push_back(y), G[y].push_back(x);
}
mt19937 rnd;
puts("10");
for (int i = 1; i <= 10; ++i) {
vector<int> z, Q;
for (int j = 1; j <= n; ++j) {
deg[j] = G[j].size();
if (deg[j] == 1) Q.push_back(j);
}
while (!Q.empty()) {
int x = Q[rnd() % Q.size()];
Q.erase(find(Q.begin(), Q.end(), x));
z.push_back(x);
for (auto v : G[x]) {
if (--deg[v] == 1) Q.push_back(v);
}
}
for (int j = 0; j < n; ++j) printf("%d%c", z[j], " \n"[j + 1 == n]);
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3800kb
input:
10 10 4 2 5 1 8 6 1 9 3 7 1 8 10 2 6 4 3 4 10 4 3 3 1 5 3 6 3 2 3 8 7 8 2 7 10 8 9 10 5 4 10 8 10 3 6 3 9 8 1 10 4 2 2 7 8 4 10 10 6 6 8 1 7 2 6 3 5 3 9 4 2 6 9 3 1 10 2 8 10 4 9 1 9 3 5 7 6 3 1 8 8 7 4 2 10 9 2 9 1 7 1 5 6 8 2 3 9 5 10 5 4 1 10 10 2 9 8 1 8 5 6 3 7 1 6 2 9 8 2 10 4 2 10 5 7 6 2 8 7...
output:
10 5 7 3 10 9 1 8 6 2 4 10 7 5 9 1 2 8 3 4 6 7 9 3 10 5 2 1 8 4 6 5 7 10 2 9 1 8 6 4 3 5 7 3 9 1 10 2 8 6 4 9 10 2 5 7 1 3 4 8 6 10 7 2 9 5 3 1 4 6 8 7 10 9 3 2 5 1 4 8 6 9 5 10 1 8 7 6 3 2 4 10 5 9 7 2 1 3 4 8 6 10 5 6 9 10 4 7 8 2 1 3 4 1 5 6 3 9 2 10 7 8 10 4 9 7 6 8 5 2 1 3 1 10 7 6 4 9 8 2 3 5 ...
result:
points 0.0 Partial correct.
Subtask #2:
score: 0
Wrong Answer
Test #2:
score: 0
Wrong Answer
time: 11ms
memory: 3796kb
input:
100 100 90 19 79 98 23 34 50 41 31 52 61 19 50 30 49 5 95 65 22 44 72 89 49 77 27 7 48 2 28 25 56 12 97 63 98 43 10 4 50 33 12 13 54 16 100 43 23 69 53 5 56 85 39 6 64 92 100 59 2 71 44 29 59 97 64 39 75 53 59 89 16 35 67 16 6 43 38 51 36 22 58 70 3 29 9 61 99 11 49 95 27 72 73 89 23 3 14 3 61 57 26...
output:
10 10 8 42 18 40 63 51 68 86 80 62 83 1 31 52 4 66 87 9 75 58 97 20 26 13 14 91 15 79 12 81 71 76 2 60 41 53 7 78 92 38 34 70 17 85 24 94 65 56 47 27 21 67 36 45 48 96 95 82 88 74 57 72 32 28 98 61 11 37 99 54 84 64 39 16 55 19 25 35 46 93 6 43 90 100 77 59 89 30 49 5 22 50 73 44 33 69 23 29 3 7 8 9...
result:
points 0.0 Partial correct.