QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#680599 | #8056. Travel 2 | MCdyc | WA | 1ms | 3560kb | C++23 | 2.2kb | 2024-10-26 21:42:22 | 2024-10-26 21:42:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int solve()
{
vector<vector<int>> g(1);
vector<bool> vis(1);
vector<set<int>> q(1);
vector<int> fa(1);
vector<map<int, int>> pos(1);
set<pair<int, int>> ans;
auto resize = [&](int x) {
if (vis.size() <= x)
{
g.resize(x + 1);
vis.resize(x + 1);
q.resize(x + 1);
fa.resize(x + 1);
pos.resize(x + 1);
}
};
auto add = [&](int x, int y) {
if (x > y)
swap(x, y);
ans.emplace(x, y);
};
int sum = 0;
int father, size;
cin >> father >> size;
resize(father);
sum += size;
vis[father] = 1;
int cnt = 0;
for (int i = 1; i <= size; i++)
{
q[father].emplace(i);
g[father].resize(size + 1);
}
while (cnt < sum)
{
int x, l;
if (q[father].empty())
{
cout << "> " << pos[father][fa[father]] << endl;
cin >> x >> l;
}
else
{
int t = *q[father].begin();
cout << "> " << t << endl;
cin >> x >> l;
g[father][t] = x;
pos[father][x] = t;
q[father].erase(q[father].begin());
add(father, x);
cnt++;
if (!vis[x])
{
resize(x);
sum += l;
fa[x] = father;
g[x].resize(l + 1);
for (int i = 1; i <= l; i++)
{
q[x].emplace(i);
}
}
else
{
if (x == fa[father])
{
cout << "> " << pos[x][father] << endl;
cin >> x >> l;
}
}
}
father = x;
vis[x] = 1;
}
cout << "!";
for (auto it : ans)
cout << " " << it.first << " " << it.second;
cout << endl;
return 0;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int test = 1;
cin >> test;
while (test--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3560kb
input:
2 1 1 2 1 1 1 2 1 Correct 1 3 2 2 1 3
output:
> 1 > 1 > 1 ! 1 2 > 1 > 1 ! 0 2 2 2
result:
wrong answer Integer parameter [name=x_i] equals to 0, violates the range [1, 4] (test case 2)