QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#766727 | #8056. Travel 2 | wangjunrui | RE | 0ms | 0kb | C++14 | 1.1kb | 2024-11-20 18:24:10 | 2024-11-20 18:24:15 |
answer
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 2505;
typedef long long ll;
map<int, int> mp[N];
int a[N], b[N];
inline int get(int x)
{
cout << "< " << x << endl;
int p, q;
cin >> p >> q;
a[p] = q;
return p;
}
vector<pair<int, int>> edges;
inline void dfs(int u, int _fa)
{
while (b[u] < a[u])
{
int v = get(++b[u]);
mp[u][v] = b[u];
edges.emplace_back(u, v);
if (edges.back().first > edges.back().second)
swap(edges.back().first, edges.back().second);
if (v == _fa)
get(mp[v][u]);
else
dfs(v, u);
}
if (_fa)
get(mp[u][_fa]);
}
inline void work()
{
int p, q;
cin >> p >> q;
a[p] = q;
dfs(p, 0);
sort(edges.begin(), edges.end());
edges.erase(unique(edges.begin(), edges.end()), edges.end());
cout << '!';
for (auto i : edges)
{
cout << ' ' << i.first << ' ' << i.second;
b[i.first] = b[i.second] = 0;
mp[i.first].clear(), mp[i.second].clear();
}
cout << endl;
edges.clear();
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T = 1;
cin >> T;
while (T--)
work();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
2 1 1
output:
< 1