QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#708133 | #8056. Travel 2 | Wolam | WA | 1ms | 3656kb | C++17 | 2.3kb | 2024-11-03 19:46:11 | 2024-11-03 19:46:15 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 3e3 + 10;
int id[maxn][maxn],d[maxn],mx,cnt[maxn],vis[maxn];
vector<pair<int,int>> edge;
void init(void)
{
for(int i=1;i<=mx;i++)
{
vis[i]=0;
cnt[i]=0;
d[i]=0;
for(int j=1;j<=mx;j++)
{
id[i][j]=0;
}
}
mx=0;
edge.clear();
}
int walk(int i)
{
cout<<"> "<<i<<endl;
int v;
cin>>v;
mx=max(mx,v);
cin>>d[v];
return v;
}
void dfs(int u,int pa)
{
if(vis[u]&&pa)
{
if(id[u][pa])
{
walk(id[u][pa]);
return;
}
for(int i=cnt[u]+1;i<=d[u];i=cnt[u]+1)
{
cnt[u]++;
int v=walk(i);
id[u][v]=i;
if(v==pa)
{
return;
}
if(u<v)
edge.emplace_back(u,v);
else
edge.emplace_back(v,u);
if(!vis[v])
{
dfs(v,u);
walk(id[v][u]);
}
else
{
dfs(v,u);
}
}
}
else
{
vis[u]=1;
for(int i=cnt[u]+1;i<=d[u];i=cnt[u]+1)
{
cnt[u]++;
int v=walk(i);
id[u][v]=i;
if(u<v)
edge.emplace_back(u,v);
else
edge.emplace_back(v,u);
if(!vis[v])
{
dfs(v,u);
walk(id[v][u]);
}
else
{
dfs(v,u);
}
}
}
}
void solve(void)
{
init();
int root;
cin>>root;
cin>>d[root];
dfs(root,0);
sort(edge.begin(),edge.end());
edge.erase(unique(edge.begin(),edge.end()),edge.end());
cout<<"! ";
for(int i=0;i<(int)edge.size();i++)
{
cout<<edge[i].first<<" "<<edge[i].second;
if(i==(int)edge.size()-1)
{
cout<<endl;
}
else
{
cout<<" ";
}
}
string s;
cin>>s;
}
int main(void)
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3568kb
input:
2 1 1 2 1 1 1 2 1 1 1 Correct 1 3 2 2 1 3 2 2 4 2 1 3 3 1 1 3 3 1 1 3 4 2 2 2 4 2 2 2 1 3 Correct
output:
> 1 > 1 > 1 > 1 ! 1 2 > 1 > 1 > 1 > 2 > 1 > 2 > 1 > 2 > 1 > 3 > 2 > 2 > 2 > 1 ! 1 2 1 3 1 4 2 4
result:
ok correct! (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3656kb
input:
1000 1 9 2 7 1 9 2 7 3 9 1 9 3 9 4 9 1 9 4 9 3 9 4 9 7 7 1 9 5 8 1 9 5 8 8 8 1 9 6 9 1 9 6 9 2 7 10 6 1 9 7 7 1 9 8 8 1 9 9 8 1 9 9 8 3 9 9 8 5 8 9 8 2 7 6 9 2 7 5 8 2 7 9 8 8 8 5 8 8 8 10 6 2 7 10 6 8 8 9 8 7 7 4 9 7 7 8 8 7 7 5 8 3 9 2 7 3 9 5 8 6 9 10 6 4 9 10 6 6 9 5 8 7 7 3 9 10 6 3 9 8 8 3 9 7...
output:
> 1 > 1 > 1 > 2 > 1 > 2 > 2 > 1 > 3 > 2 > 2 > 3 > 1 > 4 > 1 > 4 > 2 > 1 > 5 > 1 > 5 > 2 > 3 > 1 > 6 > 1 > 7 > 1 > 8 > 1 > 8 > 2 > 3 > 3 > 3 > 4 > 4 > 2 > 5 > 4 > 6 > 5 > 2 > 2 > 3 > 2 > 3 > 3 > 4 > 6 > 2 > 3 > 3 > 5 > 4 > 5 > 4 > 2 > 5 > 6 > 3 > 4 > 4 > 5 > 4 > 7 > 5 > 6 > 6 > 7 > 6 > 8 > 6 > 7 > 5 ...
result:
wrong answer you used more than 100 queries. (test case 1)