QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#659637 | #8056. Travel 2 | ucup-team4992 | RE | 186ms | 3968kb | C++14 | 1.9kb | 2024-10-19 21:04:19 | 2024-10-19 21:04:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 2510, M = 10010;
void solve() {
int tot = 0;
vector<vector<int>> G(N), stk(N);
int id, d;
cin >> id >> d;
int n = id;
G[id].resize(d + 1);
vector<int> sure(N);
int sure_cnt = 0;
auto work = [&]() {
tot++;
assert(tot <= 2 * N + 2 * M);
n = max(n, id);
if (G[id].empty()) G[id].resize(d + 1);
for (int i = 1; i <= d; i++) {
int& v = G[id][i];
if (v) continue;
cout << "> " << i << '\n';
cout.flush();
cin >> v >> d;
stk[v].push_back(id);
id = v;
return;
}
if (!sure[id]) {
sure[id]++;
sure_cnt++;
}
for (int i = 1; i <= d; i++) {
int v = G[id][i];
if (!sure[v]) {
cout << "> " << i << '\n';
cout.flush();
cin >> v >> d;
stk[v].push_back(id);
id = v;
return;
}
}
for (int i = 1; i <= d; i++) {
int v = G[id][i];
if (v == stk[id].back()) {
stk[id].pop_back();
cout << "> " << i << '\n';
cout.flush();
cin >> v >> d;
id = v;
return;
}
}
};
while (sure_cnt < n) {
work();
}
cout << "! ";
for (int i = 1; i <= n; i++) {
for (int j = G[i].size() - 1; j >= 1; j--) {
int v = G[i][j];
if (i < v) cout << i << ' ' << v << ' ';
}
}
cout << '\n';
cout.flush();
string cr;
cin >> cr;
}
int main() {
int T;
cin >> T;
while (T--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3932kb
input:
2 1 1 2 1 1 1 2 1 1 1 Correct 1 3 2 2 1 3 3 1 1 3 4 2 1 3 2 2 4 2 2 2 4 2 2 2 4 2 2 2 1 3 3 1 1 3 Correct
output:
> 1 > 1 > 1 > 1 ! 1 2 > 1 > 1 > 2 > 1 > 3 > 1 > 1 > 2 > 2 > 2 > 2 > 2 > 2 > 1 > 2 > 1 ! 1 4 1 3 1 2 2 4
result:
ok correct! (2 test cases)
Test #2:
score: 0
Accepted
time: 186ms
memory: 3968kb
input:
1000 1 9 2 7 1 9 3 9 1 9 4 9 1 9 5 8 1 9 6 9 1 9 7 7 1 9 8 8 1 9 9 8 1 9 10 6 1 9 2 7 3 9 4 9 3 9 9 8 3 9 2 7 10 6 2 7 6 9 2 7 5 8 8 8 5 8 9 8 5 8 2 7 9 8 2 7 4 9 7 7 4 9 10 6 8 8 10 6 4 9 8 8 9 8 8 8 7 7 8 8 3 9 5 8 3 9 10 6 6 9 10 6 3 9 8 8 6 9 5 8 6 9 8 8 4 9 5 8 7 7 5 8 4 9 2 7 3 9 7 7 3 9 6 9 3...
output:
> 1 > 1 > 2 > 1 > 3 > 1 > 4 > 1 > 5 > 1 > 6 > 1 > 7 > 1 > 8 > 1 > 9 > 1 > 1 > 2 > 2 > 2 > 3 > 2 > 4 > 3 > 2 > 4 > 2 > 5 > 2 > 2 > 3 > 3 > 4 > 6 > 4 > 7 > 3 > 2 > 4 > 3 > 3 > 4 > 5 > 4 > 5 > 5 > 3 > 6 > 5 > 5 > 6 > 5 > 3 > 6 > 7 > 7 > 4 > 6 > 5 > 8 > 6 > 7 > 4 > 8 > 7 > 2 > 8 > 5 > 9 > 6 > 2 > 8 > 7 ...
result:
ok correct! (1000 test cases)
Test #3:
score: -100
Runtime Error
input:
500 1 19 2 8 1 19 3 7 1 19 4 8 1 19 5 7 1 19 6 7 1 19 7 11 1 19 8 4 1 19 9 7 1 19 10 9 1 19 11 8 1 19 12 7 1 19 13 4 1 19 14 9 1 19 15 8 1 19 16 7 1 19 17 10 1 19 18 7 1 19 19 7 1 19 20 6 1 19 2 8 17 10 2 8 3 7 20 6 3 7 11 8 3 7 4 8 3 7 2 8 14 9 19 7 14 9 17 10 6 7 5 7 7 11 5 7 6 7 17 10 14 9 6 7 11...
output:
> 1 > 1 > 2 > 1 > 3 > 1 > 4 > 1 > 5 > 1 > 6 > 1 > 7 > 1 > 8 > 1 > 9 > 1 > 10 > 1 > 11 > 1 > 12 > 1 > 13 > 1 > 14 > 1 > 15 > 1 > 16 > 1 > 17 > 1 > 18 > 1 > 19 > 1 > 1 > 2 > 2 > 3 > 2 > 2 > 3 > 2 > 4 > 2 > 5 > 4 > 2 > 2 > 3 > 3 > 2 > 2 > 2 > 3 > 3 > 4 > 4 > 4 > 3 > 2 > 4 > 2 > 2 > 3 > 5 > 3 > 2 > 4 > ...