QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#331348 | #8056. Travel 2 | ucup-team992# | AC ✓ | 172ms | 5100kb | C++23 | 2.4kb | 2024-02-18 05:46:23 | 2024-02-18 05:46:24 |
Judging History
answer
//
// Created by codicon on 2/17/2024 at 10:40 AM.
//
#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(97389987);
const int MAXN = 3e3;
bool vis[MAXN];
vector<int> edges_left[MAXN];
int par[MAXN];
map<int, int> adj[MAXN];
set<pair<int, int>> edges;
pair<int, int> move(int i) {
cout << "> " << i << endl;
int x, deg; cin >> x >> deg;
return {x, deg};
}
int main() {
int t; cin >> t;
while (t--) {
memset(vis, 0, sizeof(vis));
edges.clear();
int p=0, last_edge_i=0, x, deg; // State
cin >> x >> deg;
while (true) {
if (not vis[x]) {
vis[x] = true;
// Add parent
par[x] = p;
adj[p][x] = last_edge_i;
for (auto i: views::iota(1, deg+1)) {
edges_left[x].push_back(i);
}
shuffle(edges_left[x].begin(), edges_left[x].end(), rng); // Just in case?
}
if (not empty(edges_left[x])) {
int edge_i = edges_left[x].back();
edges_left[x].pop_back();
auto [nx, ndeg] = move(edge_i);
if (nx == par[x]) {
// Moved to parent, so move back
adj[x][par[x]] = edge_i; // Add so we can move back to parent later
// Ensures cycles are only of the form "go up then go down"?
move(adj[par[x]][x]);
}
else {
// Trying edge out
edges.insert({min(x, nx), max(x, nx)});
last_edge_i = edge_i;
p = x;
x = nx;
deg = ndeg;
}
}
else {
// Finished searching this subtree
// Move back to parent
if (x == 1) {
break;
}
auto [nx, ndeg] = move(adj[x][par[x]]);
x = nx;
deg = ndeg;
}
}
cout << "!";
for (auto [x, y]: edges) {
cout << ' ' << x << ' ' << y;
}
cout << endl;
string a; cin >> a;
if (a == "Wrong") {
return 0;
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3764kb
input:
2 1 1 2 1 1 1 2 1 1 1 Correct 1 3 3 1 1 3 3 1 1 3 4 2 2 2 4 2 2 2 1 3 2 2 4 2 1 3 4 2 1 3 Correct
output:
> 1 > 1 > 1 > 1 ! 1 2 > 2 > 1 > 2 > 1 > 3 > 2 > 2 > 2 > 1 > 1 > 2 > 1 > 3 > 1 ! 1 2 1 3 1 4 2 4
result:
ok correct
Test #2:
score: 0
Accepted
time: 146ms
memory: 3748kb
input:
1000 1 9 6 9 8 8 4 9 9 8 4 9 9 8 3 9 7 7 8 8 6 9 8 8 7 7 4 9 8 8 4 9 5 8 6 9 1 9 6 9 2 7 6 9 2 7 4 9 3 9 4 9 2 7 1 9 8 8 3 9 9 8 3 9 2 7 10 6 3 9 10 6 4 9 7 7 6 9 7 7 9 8 2 7 9 8 6 9 9 8 7 7 3 9 7 7 5 8 9 8 1 9 4 9 6 9 5 8 2 7 3 9 8 8 10 6 2 7 10 6 6 9 10 6 8 8 9 8 5 8 1 9 5 8 4 9 5 8 8 8 5 8 7 7 1 ...
output:
> 5 > 5 > 8 > 9 > 8 > 9 > 2 > 8 > 3 > 7 > 5 > 5 > 2 > 5 > 8 > 6 > 6 > 1 > 5 > 2 > 4 > 2 > 7 > 2 > 2 > 7 > 1 > 7 > 6 > 3 > 2 > 4 > 3 > 6 > 6 > 4 > 3 > 7 > 8 > 6 > 4 > 6 > 7 > 7 > 6 > 5 > 8 > 4 > 3 > 1 > 3 > 8 > 4 > 4 > 2 > 7 > 3 > 2 > 3 > 5 > 3 > 3 > 4 > 3 > 1 > 4 > 8 > 6 > 2 > 2 > 7 > 1 > 8 > 5 > 1 ...
result:
ok correct
Test #3:
score: 0
Accepted
time: 95ms
memory: 3780kb
input:
500 1 19 18 7 12 7 20 6 12 7 20 6 3 7 11 8 3 7 11 8 7 11 11 8 7 11 1 19 14 9 18 7 8 4 11 8 16 7 12 7 4 8 1 19 9 7 19 7 15 8 16 7 7 11 6 7 1 19 19 7 10 9 19 7 10 9 2 8 1 19 8 4 18 7 8 4 15 8 19 7 15 8 6 7 5 7 10 9 4 8 12 7 4 8 18 7 14 9 10 9 7 11 19 7 14 9 17 10 3 7 17 10 9 7 17 10 14 9 17 10 2 8 14 ...
output:
> 17 > 7 > 6 > 6 > 6 > 2 > 3 > 2 > 3 > 7 > 5 > 7 > 1 > 13 > 6 > 6 > 2 > 4 > 6 > 2 > 1 > 8 > 3 > 7 > 3 > 4 > 6 > 1 > 18 > 6 > 7 > 6 > 6 > 1 > 7 > 4 > 6 > 3 > 7 > 7 > 4 > 2 > 4 > 8 > 3 > 2 > 7 > 4 > 9 > 5 > 9 > 2 > 3 > 7 > 6 > 9 > 5 > 4 > 3 > 2 > 4 > 4 > 7 > 6 > 4 > 6 > 5 > 1 > 9 > 4 > 2 > 5 > 2 > 4 >...
result:
ok correct
Test #4:
score: 0
Accepted
time: 167ms
memory: 4120kb
input:
100 1 99 11 4 95 12 88 8 83 7 88 8 83 7 43 12 14 8 63 4 80 6 63 4 80 6 70 9 69 9 17 7 68 4 16 7 32 7 98 7 51 7 77 11 6 9 77 11 6 9 73 6 22 5 41 7 87 5 54 8 67 10 54 8 67 10 28 6 92 13 98 7 92 13 26 10 34 8 55 9 100 4 29 11 75 10 43 12 54 8 87 5 54 8 13 6 66 6 62 12 24 10 4 10 9 9 36 6 83 7 78 8 14 8...
output:
> 10 > 2 > 11 > 3 > 3 > 3 > 4 > 7 > 2 > 3 > 2 > 3 > 6 > 7 > 3 > 6 > 2 > 6 > 4 > 6 > 2 > 3 > 5 > 3 > 4 > 4 > 2 > 4 > 3 > 7 > 8 > 7 > 9 > 3 > 12 > 7 > 7 > 6 > 6 > 2 > 4 > 9 > 2 > 8 > 3 > 3 > 6 > 6 > 4 > 11 > 6 > 5 > 7 > 2 > 5 > 5 > 3 > 4 > 5 > 4 > 2 > 5 > 9 > 2 > 1 > 98 > 3 > 5 > 6 > 2 > 3 > 2 > 2 > 2...
result:
ok correct
Test #5:
score: 0
Accepted
time: 172ms
memory: 5100kb
input:
10 1 999 501 5 1 999 501 5 704 7 620 5 407 7 967 8 653 10 746 5 11 7 237 13 559 9 181 11 652 6 522 12 652 6 522 12 113 11 237 13 890 4 1 999 620 5 704 7 620 5 214 10 1 999 767 10 182 9 1 999 821 6 394 6 483 9 933 6 599 9 350 12 678 6 1 999 851 8 754 8 99 8 154 8 391 12 945 5 391 12 945 5 54 9 312 8 ...
output:
> 500 > 1 > 500 > 3 > 4 > 2 > 5 > 2 > 10 > 3 > 7 > 5 > 6 > 7 > 6 > 10 > 6 > 2 > 4 > 6 > 1 > 619 > 3 > 4 > 4 > 1 > 766 > 2 > 1 > 820 > 5 > 6 > 6 > 2 > 3 > 8 > 1 > 850 > 2 > 8 > 8 > 7 > 7 > 4 > 7 > 3 > 9 > 1 > 887 > 3 > 6 > 2 > 7 > 1 > 225 > 10 > 1 > 179 > 4 > 4 > 2 > 2 > 4 > 7 > 7 > 7 > 3 > 1 > 638 >...
result:
ok correct
Test #6:
score: 0
Accepted
time: 138ms
memory: 4796kb
input:
4 1 999 501 15 668 18 833 23 670 21 76 20 82 23 125 22 841 15 270 25 106 22 779 19 492 18 763 21 702 18 249 16 317 17 968 21 861 17 418 25 263 19 596 22 724 16 461 14 946 14 1 999 620 23 278 18 220 20 456 22 705 24 211 17 924 18 496 21 787 16 834 18 480 12 834 18 480 12 1 999 767 14 735 27 910 23 98...
output:
> 500 > 12 > 16 > 3 > 14 > 6 > 20 > 3 > 7 > 8 > 8 > 10 > 10 > 18 > 9 > 4 > 17 > 19 > 10 > 9 > 17 > 5 > 2 > 13 > 1 > 619 > 6 > 9 > 5 > 11 > 24 > 3 > 4 > 9 > 10 > 8 > 6 > 8 > 1 > 766 > 11 > 27 > 9 > 4 > 8 > 14 > 3 > 6 > 14 > 7 > 10 > 5 > 16 > 20 > 8 > 6 > 4 > 9 > 8 > 5 > 21 > 13 > 2 > 7 > 8 > 12 > 9 >...
result:
ok correct
Test #7:
score: 0
Accepted
time: 171ms
memory: 4364kb
input:
4 1 199 74 101 33 89 52 93 72 94 6 103 172 100 98 95 66 108 17 97 37 104 82 107 40 91 80 96 128 99 155 103 107 92 137 98 150 105 137 98 150 105 67 96 85 92 68 106 183 109 163 100 169 100 7 110 84 88 132 99 76 99 187 107 134 99 62 95 65 100 2 106 162 104 199 104 192 112 71 100 158 96 187 107 8 109 18...
output:
> 73 > 56 > 26 > 60 > 5 > 10 > 79 > 42 > 17 > 56 > 66 > 40 > 79 > 23 > 28 > 30 > 17 > 30 > 29 > 30 > 96 > 46 > 28 > 45 > 60 > 88 > 28 > 82 > 62 > 64 > 64 > 73 > 50 > 57 > 24 > 21 > 100 > 16 > 9 > 7 > 13 > 84 > 74 > 5 > 96 > 18 > 12 > 18 > 79 > 5 > 32 > 85 > 53 > 74 > 88 > 63 > 27 > 20 > 64 > 43 > 3 ...
result:
ok correct
Test #8:
score: 0
Accepted
time: 109ms
memory: 4688kb
input:
4 1 140 63 140 48 140 78 140 127 140 100 140 69 140 67 140 42 140 4 140 57 140 14 140 111 140 59 140 109 140 46 140 130 140 43 140 15 140 8 140 91 140 50 140 44 140 41 140 125 140 44 140 105 140 132 140 138 140 124 140 45 140 82 140 94 140 11 140 35 140 76 140 127 140 88 140 54 140 29 140 11 140 119...
output:
> 62 > 48 > 77 > 126 > 100 > 69 > 67 > 42 > 4 > 56 > 14 > 110 > 59 > 108 > 46 > 129 > 43 > 15 > 8 > 90 > 50 > 44 > 41 > 124 > 44 > 104 > 131 > 137 > 124 > 45 > 81 > 93 > 11 > 34 > 75 > 126 > 88 > 54 > 29 > 11 > 118 > 117 > 62 > 137 > 64 > 51 > 110 > 71 > 55 > 126 > 132 > 77 > 87 > 27 > 42 > 11 > 8 >...
result:
ok correct
Test #9:
score: 0
Accepted
time: 89ms
memory: 4852kb
input:
4 1 2498 2171 2 2500 2498 737 2 1 2498 581 2 1 2498 581 2 2500 2498 1959 2 1 2498 761 2 2500 2498 510 2 1 2498 1249 2 1 2498 1249 2 2500 2498 604 2 1 2498 1665 2 1 2498 1665 2 2500 2498 1433 2 1 2498 1690 2 1 2498 1690 2 2500 2498 2194 2 2500 2498 2194 2 1 2498 493 2 1 2498 493 2 2500 2498 727 2 1 2...
output:
> 2170 > 2 > 736 > 1 > 580 > 1 > 580 > 2 > 1958 > 1 > 760 > 2 > 509 > 1 > 1248 > 1 > 1248 > 2 > 603 > 1 > 1664 > 1 > 1664 > 2 > 1432 > 1 > 1689 > 1 > 1689 > 2 > 2193 > 2 > 2193 > 1 > 492 > 1 > 492 > 2 > 726 > 1 > 242 > 1 > 242 > 2 > 1717 > 1 > 2419 > 2 > 953 > 2 > 953 > 1 > 276 > 2 > 1510 > 2 > 1510...
result:
ok correct
Extra Test:
score: 0
Extra Test Passed