QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#659546 | #8056. Travel 2 | ucup-team4992 | ML | 1ms | 3884kb | C++14 | 1.5kb | 2024-10-19 20:37:52 | 2024-10-19 20:37:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 2510, M = 10010;
void solve() {
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 = [&]() {
n = max(n, id);
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 (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: 3884kb
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 4 2 2 2 4 2 2 2 4 2 1 3 3 1 1 3 Correct
output:
> 1 > 1 > 1 > 1 ! 1 2 > 1 > 1 > 2 > 1 > 3 > 1 > 3 > 2 > 2 > 2 > 2 > 1 > 2 > 1 ! 1 4 1 3 1 2 2 4
result:
ok correct! (2 test cases)
Test #2:
score: -100
Memory Limit Exceeded
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 10 6 2 7 3 9 4 9 3 9 9 8 3 9 2 7 10 6 8 8 5 8 8 8 10 6 4 9 7 7 4 9 10 6 6 9 2 7 6 9 10 6 3 9 5 8 9 8 5 8 2 7 5 8 3 9 10 6 3 9 8 8 9 8 2 7 9 8 8 8 7 7 8 8 3 9 7 7 5 8 6 9 5 8 7 7 3 9 6 9 8 8 6 9 3 9 6 9 9 8 7 7 9 8 6 9 ...
output:
> 1 > 1 > 2 > 1 > 3 > 1 > 4 > 1 > 5 > 1 > 6 > 1 > 7 > 1 > 8 > 1 > 9 > 1 > 9 > 2 > 2 > 2 > 2 > 3 > 2 > 4 > 3 > 3 > 2 > 2 > 3 > 4 > 3 > 2 > 4 > 5 > 2 > 4 > 3 > 6 > 5 > 3 > 3 > 4 > 5 > 5 > 6 > 6 > 7 > 4 > 4 > 6 > 5 > 5 > 3 > 6 > 8 > 4 > 6 > 4 > 7 > 5 > 9 > 5 > 7 > 6 > 9 > 7 > 6 > 6 > 7 > 8 > 7 > 9 > 5 ...