QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#356013 | #8239. Mysterious Tree | USTC_fish_touching_team# | WA | 0ms | 1612kb | C++14 | 1.1kb | 2024-03-17 14:43:39 | 2024-03-17 14:43:40 |
Judging History
answer
#include<cstdio>
using namespace std;
int T,n;
int query(int u,int v){
printf("? %d %d\n",u,v);
fflush(stdout);
int res=0;
scanf("%d",&res);
return res;
}
void get(int u){
printf("! %d\n",u);
fflush(stdout);
}
int main(){
scanf("%d",&T);
while(T--){
scanf("%d",&n);
int cnt=0,pos;
for(int i=1;i<=n;i+=2){
int res=query(i,i+1);
if(res){
cnt++;
pos=i;
}
}
if(cnt>=2){
get(1);
continue;
}
int a,b,x,y;
if(n%2==1){
int res=query(n-1,n);
if(res){
if(cnt==1&&pos<n-2){
get(1);
continue;
}else{
a=n-1,b=n;
}
}else{
if(cnt==0){
get(1);
continue;
}else{
a=pos;b=pos+1;
}
}
}else{
if(cnt==0){
get(1);
continue;
}else{
a=pos,b=pos+1;
}
}
if(a==1)x=3,y=4;
else x=1,y=2;
int ra=query(a,x);
int rb=query(b,x);
if(ra==0&&rb==0){
get(1);
continue;
}
if(rb==0){
if(query(a,y))get(2);
else get(1);
}else{
// assert(ra==0);
if(query(b,y))get(2);
else get(1);
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 1612kb
input:
2 4 1 1 4 0 1 1 0 1
output:
? 1 2 ? 3 4 ! 1 ? 1 2 ? 3 4 ? 3 1 ? 4 1 ? 3 2 ! 2
result:
ok Correct (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 1604kb
input:
87 13 0 0 0 0 0 1
output:
? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 13 14
result:
wrong answer Integer 14 violates the range [1, 13] (test case 1)