QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#655038#8239. Mysterious Tree111111qqqqqqWA 1ms3604kbC++141.6kb2024-10-18 23:57:022024-10-18 23:57:03

Judging History

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

  • [2024-10-18 23:57:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3604kb
  • [2024-10-18 23:57:02]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define cmin(a,b) a=min(a,b)
#define cmax(a,b) a=max(a,b)
#define modd(a,b) a=a%b
#define pb push_back
#define db double
#define lowbit(x) x&(-x)
#define cerr(x) cout<<#x<<"="<<x<<endl
#define fi first
#define se second
const ll mod=1e9+7;
#define N 1010
int n;
int a,b;
bool f=0;
ll ksm(ll a,ll b) {ll ans=1,bs=a;while(b) {if(b&1) ans=ans*bs%mod;bs=bs*bs%mod;b>>=1;}return ans;}
int query(int x,int y) {
    cout<<"? "<<x<<" "<<y<<endl;
    int u;cin>>u;
    return u;
}
void out(int x) {
    cout<<"! "<<x<<endl;
}
void solve() {
    cin>>n;
    if(n&1) {
        for(int i=1;i<=n-2;i+=2) {
            int g=query(i,i+1);
            f|=g;
            if(g) a=i,b=i+1;
        }
        int g=query(n-1,n);
        f|=g;
        if(g) a=n-1,b=n;
    }
    else {
        bool f=0;
        for(int i=1;i<=n-1;i+=2) {
            int g=query(i,i+1);
            f|=g;
            if(g) a=i,b=i+1;
        }
    }
    if(!f) {out(1);return;}
    int c=0,d=0;
    for(int i=1;i<=n;i++) {
        if(i!=a && i!=b) {c=i;break;}
    }
    for(int i=1;i<=n;i++) {
        if(i!=a && i!=b && i!=c) {d=i;break;}
    }
    int u=query(a,c),v=query(b,c),o;
    if(!u && !v) {out(1);return;}
    if(u) {
        o=query(a,d);
        if(o) out(2);
        else out(1);
    }
    else  {
        o=query(b,d);
        if(o) out(2);
        else out(1);
    }
}
int main() {
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int T;
    cin>>T;
    while(T--) 
    solve();
    return 0;
}

詳細信息

Test #1:

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

input:

2
4
1
1
4
0
1

output:

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

result:

wrong answer Wrong prediction (test case 2)