QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#770756 | #8056. Travel 2 | yangjl | RE | 0ms | 3552kb | C++20 | 2.8kb | 2024-11-21 23:55:08 | 2024-11-21 23:55:08 |
Judging History
answer
/**
* author: yangjl
* created: 2024.11.21 21:33:55
**/
#include <bits/stdc++.h>
#ifdef YJL
#include "debug.h"
#else
#define debug(...)0
#endif
using namespace std;
using ll = long long;
template<class T>
istream& operator>>(istream& is, vector<T>& v) {
for(auto& x : v) {
is >> x;
}
return is;
}
int qn;
pair<int, int> query(int i) {
++qn;
++i;
cout << "> " << i << endl;
int u, d;
cin >> u >> d;
--u;
return {u,d};
}
void answer(vector<int>const& edges) {
cout << "! ";
for(int x : edges) {
cout << " " << x + 1;
}
cout << endl;
string response;
cin >> response;
assert(response == "Correct");
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
// #ifdef YJL
// freopen("oo.in", "r", stdin);
// freopen("oo.out", "w", stdout);
// #endif
int tt;
cin >> tt;
while(tt--) {
qn = 0;
int u, d;
cin >> u >> d;
--u;
vector<vector<int>> g;
vector<int> id;
auto extend = [&](int u, int d) {
if(u >= g.size()) {
g.resize(u + 1);
id.resize(u + 1);
}
if(g[u].empty()) {
g[u].resize(d, -1);
} else {
assert(d == g[u].size());
}
};
extend(u, d);
function<void(int, int)> dfs = [&](int u, int pre) {
debug(u, pre);
debug(g);
while(true) {
while(id[u] < g[u].size() and g[u][id[u]] != -1) {
id[u]++;
}
if(id[u] == g[u].size()) {
auto it = find(g[u].begin(), g[u].end(), pre);
if(it == g[u].end()) {
if(pre != -1) {
debug(u, pre, g[u]);
}
assert(pre == -1);
return;
}
int i = it - g[u].begin();
// debug(u, pre, g, id);
assert(query(i).first == pre);
return;
}
auto [v, d] = query(id[u]);
extend(v, d);
g[u][id[u]] = v;
id[u]++;
dfs(v, u);
}
};
dfs(u, -1);
debug(g);
vector<int> es;
for(int i = 0; i < g.size(); ++i) {
for(int j : g[i]) {
assert(j != -1);
if(i < j) {
es.push_back(i);
es.push_back(j);
}
}
}
assert(qn <= g.size() * 2 + es.size());
answer(es);
}
return 0;
}
/*
1
1 3
4 2
2 2
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
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 2 2 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 > 1 ! 1 2 1 3 1 4 2 4
result:
ok correct! (2 test cases)
Test #2:
score: -100
Runtime Error
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 ...