QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#626084#8239. Mysterious TreeAlbert711WA 1ms3708kbC++201.2kb2024-10-09 23:04:052024-10-09 23:04:05

Judging History

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

  • [2024-10-09 23:04:05]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3708kb
  • [2024-10-09 23:04:05]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
// #define int long long
#define ll long long
#define db double
const int mod=998244353;
const int N=2e5+5;

int ask(int x,int y){
    int tmp;
    cout<<"? "<<x<<" "<<y<<endl;
    cin>>tmp;
    return tmp;
}
void abt(){
    int n;
    cin>>n;
    int t1,t2;
    for(int i=1;i<n;i+=2){
        int tmp;
        tmp=ask(i,i+1);
        if(tmp==1){
            t1=i;t2=i+1;
            break;
        }
    }
    if(n%2==1){
        int tmp;
        tmp=ask(1,n);
        if(tmp==1){
            t1=1;t2=n;
        }
    }
    int t3=n-1,t4=n;
    if(t1==1&&t2==n){
        t3=2,t4=3;
    }else if(t1>n/2){
        t3=1,t4=2;
    }else{
        t3=n-1,t4=n;
    }
    int jud=0;
    if(ask(t1,t3)){
        if(ask(t1,t4)){
            jud=1;
        }
    }else{
        if(ask(t2,t3)){
            if(ask(t2,t4)){
                jud=1;
            }
        }
    }
    if(jud){
        cout<<"! "<<2<<endl;
    }else{
        cout<<"! "<<1<<endl;
    }

}

signed main(){
    // ios::sync_with_stdio(false);
    // cin.tie(nullptr);cout.tie(nullptr);
    int T=1;
    cin>>T;
    while(T--) abt();
    return 0;
}




Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3560kb

input:

87
13
0
0
0
0
0
1
0
0
1
1
15
0
0
0
0
0
0
1
0
1
1
7
0
0
0
1
0
1
1
15
0
0
0
1
1
0
0
19
0
0
0
0
0
1
0
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
? 1 13
? 11 1
? 12 1
? 12 2
! 2
? 1 2
? 3 4
? 5 6
? 7 8
? 9 10
? 11 12
? 13 14
? 1 15
? 13 1
? 13 2
! 2
? 1 2
? 3 4
? 5 6
? 1 7
? 1 2
? 7 2
? 7 3
! 2
? 1 2
? 3 4
? 5 6
? 7 8
? 1 15
? 1 2
? 15 2
! 1
? 1 2
? 3 4
? 5 6
? 7 8
? 9 10
? 11 12
? 1 19
? 11 1
? 11 2
! 2...

result:

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