QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#695178#8239. Mysterious TreeGLLF234WA 1ms3632kbC++201.8kb2024-10-31 19:28:092024-10-31 19:28:10

Judging History

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

  • [2024-10-31 19:28:10]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3632kb
  • [2024-10-31 19:28:09]
  • 提交

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<<"! 2"<<endl;
                    return ;
                } 
                else {
                    cout<<"! 1"<<endl;
                    return ;
                }
            }
            else{
                cout<<"?"<<" "<<i+1<<" "<<k<<endl;
                fflush(stdout);
                int z;
                cin>>z;
                if(z==0){
                    cout<<"! 1"<<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<<"! 1"<<endl;
                        return ;
                    }
                    else{
                        cout<<"! 2"<<endl;
                        return ;
                    }
                }
            }
        }
    }
    cout<<"! 1"<<endl;
}
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T;
    cin>>T;
    while(T--){
        slove();
    }
}

詳細信息

Test #1:

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

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

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

output:

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

result:

wrong answer Integer 8 violates the range [1, 7] (test case 3)