QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#766806 | #8056. Travel 2 | wangjunrui | RE | 0ms | 0kb | C++14 | 1.3kb | 2024-11-20 18:42:11 | 2024-11-20 18:42:15 |
answer
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 2505;
typedef long long ll;
int a[N], b[N];
int n;
inline int get(int x)
{
cout << "> " << x << endl;
int p, q;
cin >> p >> q;
a[p] = q;
n = max(n, p);
return p;
}
vector<pair<int, int>> edges;
vector<int> g[N];
int mp[N][N];
bool vis[N];
inline void dfs(int u)
{
if (b[u] < a[u])
{
int v = get(++b[u]);
mp[u][v] = b[u];
g[u].push_back(v);
dfs(v);
return;
}
vis[u] = true;
for (int v : g[u])
{
if (!vis[v])
{
get(mp[u][v]);
dfs(v);
get(mp[v][u]);
}
}
}
inline void work()
{
int p, q;
cin >> p >> q;
n = p;
a[p] = q;
dfs(p);
for (int u = 1; u <= n; ++u)
for (int v : g[u])
if (u < v)
edges.emplace_back(u, v);
sort(edges.begin(), edges.end());
edges.erase(unique(edges.begin(), edges.end()), edges.end());
cout << '!';
for (auto i : edges)
{
cout << ' ' << i.first << ' ' << i.second;
mp[i.first][i.second] = mp[i.second][i.first] = 0;
}
cout << endl;
for (int i = 1; i <= n; ++i)
{
b[i] = 0;
vis[i] = 0;
g[i].clear();
}
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 2 1 1 1 2 1 1 1 Correct 1 3 2 2
output:
> 1 > 1 > 1 > 1 ! 1 2 > 1