QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#714164#8056. Travel 2frankly6WA 21ms3696kbC++171.8kb2024-11-05 21:58:392024-11-05 21:58:42

Judging History

你现在查看的是最新测评结果

  • [2024-11-05 21:58:42]
  • 评测
  • 测评结果:WA
  • 用时:21ms
  • 内存:3696kb
  • [2024-11-05 21:58:39]
  • 提交

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]&&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: 100
Accepted
time: 1ms
memory: 3648kb

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
! 2 1 
> 1
> 1
> 1
> 2
> 1
> 2
> 1
> 2
> 1
> 3
> 2
> 2
> 2
> 1
! 1 2 4 2 1 4 3 1 

result:

ok correct! (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 21ms
memory: 3696kb

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
4 9
7 7
8 8
5 8
8 8
10 6
2 7
10 6
8 8
9 8
1 9
8 8
7 7
5 8
9 8
3 9
9 8
5 8
2 7
6 9
10 6
4 9
10 6
6 9
5 8
3 9
2 7
3 9
5 8
6 9
8 8
3 9
10 6
3 9
8 8
6 9
3 9
7 7
3 9
6 9
9 8
2 7
5 8
7 7
9 8
8 8
9...

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
> 2
> 3
> 3
> 2
> 2
> 3
> 2
> 3
> 3
> 4
> 1
> 7
> 5
> 4
> 3
> 2
> 3
> 3
> 4
> 4
> 3
> 4
> 4
> 5
> 4
> 5
> 4
> 2
> 5
> 6
> 5
> 6
> 6
> 6
> 7
> 7
> 6
> 8
> 5
> 9
> 7
> 4
> 5
> 7
> 6
> 5
> 4
> 6
> 7
> 8
...

result:

wrong answer the edges you recovered is incorrect (test case 154)