QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#695157#8239. Mysterious TreeGLLF234WA 1ms3664kbC++201.8kb2024-10-31 19:26:102024-10-31 19:26:11

Judging History

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

  • [2024-10-31 19:26:11]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3664kb
  • [2024-10-31 19:26:10]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
double a[100005];
void slove(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i+=2){
        cout<<'?'<<" "<<i<<" "<<i+1<<endl;
        fflush(stdout);
        int x;
        cin>>x;
        if(x==1){
            int k=i+2;
            if(k>n) k%=n;
            cout<<"?"<<" "<<i<<" "<<k<<endl;
            fflush(stdout);
            int y;
            cin>>y;
            if(y==1){
                k=i+3;
                if(k>n) k%=n;
                cout<<"?"<<" "<<i<<" "<<k<<endl;
                fflush(stdout);
                int z;
                cin>>z;
                if(z==1){
                    cout<<"! 1"<<endl;
                    return ;
                } 
                else {
                    cout<<"! 2"<<endl;
                    return ;
                }
            }
            else{
                cout<<"?"<<" "<<i+1<<" "<<k<<endl;
                fflush(stdout);
                int z;
                cin>>z;
                if(z==0){
                    cout<<"! 2"<<endl;
                    return ;
                }
                else{
                    k=i+3;
                    if(k>n) k=k%n;
                    cout<<"?"<<" "<<i+1<<" "<<k<<endl;
                    fflush(stdout);
                    int o;
                    cin>>o;
                    if(o==0){
                        cout<<"! 2"<<endl;
                        return ;
                    }
                    else{
                        cout<<"! 1"<<endl;
                        return ;
                    }
                }
            }
        }
    }
    cout<<"! 2"<<endl;
}
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T;
    cin>>T;
    while(T--){
        slove();
    }
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3664kb

input:

2
4
1
0
1
0

output:

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

result:

wrong answer Wrong prediction (test case 1)