QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#626086 | #8239. Mysterious Tree | Albert711 | WA | 2ms | 3628kb | C++20 | 1.3kb | 2024-10-09 23:05:31 | 2024-10-09 23:05:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
// #define int long long
#define ll long long
#define db double
const int mod=998244353;
const int N=2e5+5;
int n;
int ask(int x,int y){
int tmp;
if(x>n) cout<<"0"<<endl;
if(y>n) cout<<"0"<<endl;
cout<<"? "<<x<<" "<<y<<endl;
cin>>tmp;
return tmp;
}
void abt(){
cin>>n;
int t1,t2;
for(int i=1;i<n;i+=2){
int tmp;
tmp=ask(i,i+1);
if(tmp==1){
t1=i;t2=i+1;
break;
}
}
if(n%2==1){
int tmp;
tmp=ask(1,n);
if(tmp==1){
t1=1;t2=n;
}
}
int t3,t4;
if(t1==1&&t2==n){
t3=2,t4=3;
}else if(t1>n/2){
t3=1,t4=2;
}else{
t3=n-1,t4=n;
}
int jud=0;
if(ask(t1,t3)){
if(ask(t1,t4)){
jud=1;
}
}else{
if(ask(t2,t3)){
if(ask(t2,t4)){
jud=1;
}
}
}
if(jud){
cout<<"! "<<2<<endl;
}else{
cout<<"! "<<1<<endl;
}
}
signed main(){
// ios::sync_with_stdio(false);
// cin.tie(nullptr);cout.tie(nullptr);
int T=1;
cin>>T;
while(T--) abt();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
input:
2 4 1 0 1 0 4 0 1 1 1
output:
? 1 2 ? 1 3 ? 2 3 ? 2 4 ! 1 ? 1 2 ? 3 4 ? 3 1 ? 3 2 ! 2
result:
ok Correct (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3628kb
input:
87 13 0 0 0 0 0 1 0 0 1 1 15 0 0 0 0 0 0 1 0 1 1 7 0 0 0 1 0 1 1 15 0 0 0 1 1 0 0 19 0 0 0 0 0 1 0 1 1 20 0 0 0 0 0 0 0 0 0 0
output:
? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 1 13 ? 11 1 ? 12 1 ? 12 2 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 13 14 ? 1 15 ? 13 1 ? 13 2 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 1 7 ? 1 2 ? 7 2 ? 7 3 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 1 15 ? 1 2 ? 15 2 ! 1 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 1 19 ? 11 1 ? 11 2 ! 2...
result:
wrong answer Integer -120962848 violates the range [1, 20] (test case 6)