QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#714163 | #8056. Travel 2 | frankly6 | WA | 0ms | 3636kb | C++17 | 1.8kb | 2024-11-05 21:57:00 | 2024-11-05 21:57:04 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<map>
#include<cstring>
using namespace std;
typedef pair<int,int> PII;
const int MX=2550;
const int MZ=10000;
int T, N, M, cnt;
int now=0, num=0, pre=0, nm=0;
int id[MX], siz[MX], fa[MX], tag[MX];
bool g[MX][MX];
int k[MX][MX], vis[MX];
PII ans[MZ];
int read()
{
int r=0, f=1; char ch=getchar();
while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
while(ch>='0'&&ch<='9') {r=r*10+ch-'0'; ch=getchar();}
return r*f;
}
void ask(int e)
{
cout << "> " << e << '\n';
cout.flush();
pre=now, nm=num;
cin >> now >> num;
k[pre][now]=e;
if(!vis[now]) vis[now]=1, fa[now]=pre;
}
int main()
{
// freopen("testdata.in","r",stdin);
cin >> T;
while(T--)
{
cnt=0;
int c=1;
cin >> now >> num;
// ask(++id[now]);
vis[1]=1;
while(now!=1||id[now]!=num)
{
if(id[now]==num) //full size return
{
// cout << "size\n";
ask(k[now][fa[now]]);
continue;
}
// cout << "search, id=" << id[now] << '\n';
if(!g[now][pre]) g[now][pre]=g[pre][now]=1, ans[++cnt]={now,pre};
ask(++id[now]);
if(fa[pre]==now) //tree edge return
{
ask(k[now][pre]);
}
}
cout << "! ";
for(int i=1;i<=cnt;i++)
{
auto [u,v]=ans[i];
cout << u << " " << v << " ";
fa[u]=fa[v]=0;
siz[u]=siz[v]=0;
id[u]=id[v]=0;
tag[u]=tag[v]=0;
vis[u]=vis[v]=0;
g[u][v]=g[v][u]=k[v][u]=k[u][v]=0;
}
cout << '\n';
cout.flush();
string s; cin >> s;
}
return (0-0);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3636kb
input:
2 1 1 2 1 1 1 2 1 1 1
output:
> 1 > 1 > 1 > 1 ! 1 0 2 1
result:
wrong answer Integer parameter [name=y_i] equals to 0, violates the range [1, 2] (test case 1)