QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#655028 | #8239. Mysterious Tree | 111111qqqqqq | WA | 1ms | 3716kb | C++14 | 1.5kb | 2024-10-18 23:52:27 | 2024-10-18 23:52:27 |
Judging History
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=query(a,d);
if(!u && !v) {out(1);return;}
if(u && o) {out(2);return;}
if(v && o) {out(2);return;}
out(1);
}
int main() {
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int T;
cin>>T;
while(T--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3716kb
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)