QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#668278#8239. Mysterious Treeqzez#WA 1ms3812kbC++14954b2024-10-23 13:17:302024-10-23 13:17:30

Judging History

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

  • [2024-10-23 13:17:30]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3812kb
  • [2024-10-23 13:17:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int query(int u,int v){
    cout<<"? "<<u<<' '<<v<<endl;
    int x;
    cin>>x;
    return x;
}
int T,n;
void get(){
    cin>>n;
    int x=1;
    for(;x+1<=n;x+=2){
        if(query(x,x+1))break;
    }
    if(x+1<=n){
        vector<int>p;
        for(int i=1;i<=n;i++)if(i!=x&&i!=x+1)p.push_back(i);
        if(query(x,p[0])){
            if(query(x,p[1]))cout<<"! 2"<<endl;
            else cout<<"! 1"<<endl;
        }else{
            if(query(x+1,p[0])){
                if(query(x+1,p[1]))cout<<"! 2"<<endl;
                else cout<<"! 1"<<endl;
            }else cout<<"! 1"<<endl;
        }
    }else{
        for(int i=1;i<=3;i++){
            if(!query(x,i))return cout<<"! 1"<<endl,void();
        }
        cout<<"! 2"<<endl;
    }
}
int main(){
    // freopen(".in","r",stdin);
    // freopen(".out","w",stdout);
    for(cin>>T;T--;)get();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3812kb

input:

2
4
1
0
1
0
4
0
1
1
1

output:

? 1 2
? 1 3
? 2 3
? 2 4
! 1
? 1 2
? 3 4
? 3 1
? 3 2
! 2

result:

ok Correct (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3604kb

input:

87
13
0
0
0
0
0
1
0
1
1
15
0
0
0
0
0
0
1
1
1
7
0
0
0
1
1
1
15
0
0
0
1
0
0
19
0
0
0
0
0
1
1
1
20
0
0
0
0
0
0
0
0
0
0

output:

? 1 2
? 3 4
? 5 6
? 7 8
? 9 10
? 11 12
? 11 1
? 12 1
? 12 2
! 2
? 1 2
? 3 4
? 5 6
? 7 8
? 9 10
? 11 12
? 13 14
? 13 1
? 13 2
! 2
? 1 2
? 3 4
? 5 6
? 7 1
? 7 2
? 7 3
! 2
? 1 2
? 3 4
? 5 6
? 7 8
? 7 1
? 8 1
! 1
? 1 2
? 3 4
? 5 6
? 7 8
? 9 10
? 11 12
? 11 1
? 11 2
! 2
? 1 2
? 3 4
? 5 6
? 7 8
? 9 10
? 1...

result:

wrong answer Integer 21 violates the range [1, 20] (test case 6)