QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#770629 | #8056. Travel 2 | yangjl | RE | 0ms | 0kb | C++20 | 2.3kb | 2024-11-21 22:47:32 | 2024-11-21 22:47:32 |
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;
}
pair<int, int> query(int i) {
++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);
int tt;
cin >> tt;
while(tt--) {
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);
g[u].resize(d, -1);
} else {
assert(d == g[u].size());
}
};
extend(u, d);
function<void(int, int)> dfs = [&](int u, int pre) {
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()) {
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);
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);
}
}
}
answer(es);
}
return 0;
}
/*
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
2 1 1 2 1 1 1 2 1 Correct 1 3 2 2 1 3 3 1 1 3 4 2 1 3 4 2
output:
> 1 > 1 > 1 ! 1 2 > 1 > 1 > 2 > 1 > 3 > 1 > 3