QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#350128#8239. Mysterious Treemc020207#WA 1ms3624kbC++171.5kb2024-03-10 14:34:452024-03-10 14:34:45

Judging History

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

  • [2024-03-10 14:34:45]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3624kb
  • [2024-03-10 14:34:45]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define For(i, a, b) for(int i = (a);i <= (b);i++) 
#define Rof(i, a, b) for(int i = (a);i >= (b);i--)
int ask(int x,int y){
    cout<<"? "<<x<<" "<<y<<endl;
    int t;cin>>t;
    return t;
}
int n;
int st[10],top;
int getn(){
    For(i,1,n){
        bool f=0;
        For(j,1,top){
            if (i==st[j]){
                f=1;
                break;
            }
        }
        if (!f) return i;
    }
}
void Main(){
    top=0;
    cin>>n;
    bool f=0;
    int x,y;
    for (int i=1;i<=n;i+=2){
        if (ask(i,i%n+1)){
            x=i,y=i&n+1;
            f=1;
            break;
        }
    }
    // if (n%2){
    //     if(ask(1,n)){
    //         x=1,y=n;
    //         f=1;
    //     }
    // }
    if (!f){
        cout<<"! "<<1<<endl;
        return ;
    }
    st[++top]=x,st[++top]=y;
    int z=getn();
    if (ask(x,z)){
        st[++top]=z;
        int w=getn();
        if (ask(x,w)){
            cout<<"! "<<2<<endl;
        }else{
            cout<<"! "<<1<<endl;
        }
    }else swap(x,y);
    if (ask(x,z)){
        st[++top]=z;
        int w=getn();
        if (ask(x,w)){
            cout<<"! "<<2<<endl;
        }else{
            cout<<"! "<<1<<endl;
        }
    }else{
        cout<<"! "<<1<<endl;
    }
}
int main(){
    std::ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int T;cin>>T;
    while (T--) Main();
}

详细

Test #1:

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

input:

2
4
1
1
0
4
0
1

output:

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

result:

wrong answer Wrong prediction (test case 2)