QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#350144#8239. Mysterious Treemc020207#WA 1ms3668kbC++171.6kb2024-03-10 14:40:212024-03-10 14:40:22

Judging History

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

  • [2024-03-10 14:40:22]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3668kb
  • [2024-03-10 14:40:21]
  • 提交

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();
    cout<<z<<endl;
    if (ask(x,z)){
        st[++top]=z;
        int w=getn();
        if (ask(x,w)){
            cout<<"! "<<2<<endl;
            return ;
        }else{
            cout<<"! "<<1<<endl;
            return ;
        }
    }else swap(x,y);
    if (ask(x,z)){
        st[++top]=z;
        int w=getn();
        if (ask(x,w)){
            cout<<"! "<<2<<endl;
            return ;
        }else{
            cout<<"! "<<1<<endl;
            return ;
        }
    }else{
        cout<<"! "<<1<<endl;
        return ;
    }
}
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: 3668kb

input:

2
4
1

output:

? 1 2
3
? 1 3

result:

wrong answer Token parameter [name=type] equals to "3", doesn't correspond to pattern "?|!" (test case 1)