QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#402872 | #8239. Mysterious Tree | zhi0929 | WA | 1ms | 3560kb | C++14 | 811b | 2024-05-01 17:03:52 | 2024-05-01 17:03:53 |
Judging History
answer
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cmath>
#include<stack>
#include<bitset>
#include<iomanip>
#include<iostream>
#include<algorithm>
//#pragma GCC optimize("O0")
using namespace std;
#define int long long
signed main(){
int N;cin>>N;
while(N--){
int n;cin>>n;int x;int a;
for(a=1;a<n;a++){
cout<<"? "<<a<<" "<<a+1<<endl;
fflush(stdout);
cin>>x;
if(x)break;
}int x1=-1,x2=-1;int x3=0,x4=0;
for(int b=1;b<=n;b++){
if(b==a||b==a+1)continue;
cout<<"? "<<b<<" "<<a+1<<endl;
fflush(stdout);
if(x1==-1)cin>>x1;
else cin>>x2;
if(x2!=-1)break;}
if(a==1){cout<<"? 1 3"<<endl;fflush(stdout);cin>>x3;cout<<"? 1 4"<<endl;fflush(stdout);cin>>x4;}
if((x1&&x2)||(x3&&x4))cout<<"! 2"<<endl;
else cout<<"! 1"<<endl;
fflush(stdout);}}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3560kb
input:
2 4 1 1 0 0 0 4 0 1 1 1
output:
? 1 2 ? 3 2 ? 4 2 ? 1 3 ? 1 4 ! 1 ? 1 2 ? 2 3 ? 1 3 ? 4 3 ! 2
result:
ok Correct (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3508kb
input:
87 13 0 0 0 0 0 0 0 0 0 0
output:
? 1 2 ? 2 3 ? 3 4 ? 4 5 ? 5 6 ? 6 7 ? 7 8 ? 8 9 ? 9 10 ? 10 11 ? 11 12
result:
wrong answer Too many queries , n = 13 , now_q 11 (test case 1)