QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#778786 | #8239. Mysterious Tree | guodong# | WA | 1ms | 3604kb | C++17 | 1.2kb | 2024-11-24 16:16:27 | 2024-11-24 16:16:28 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n;
int ask(int x,int y){
cout << "? " << x << " " << y << '\n';
cout.flush();
int t;
cin >> t;
return t;
}
void answer(int x){
cout << "! " << x << '\n';
cout.flush();
}
void check(int x,int y){
vector<int> other;
for(int i = 1; i <= n && other.size() < 2; ++i){
if(i != x && i != y)
other.emplace_back(i);
}
int a = ask(x,other[0]);
int b = ask(y,other[1]);
if(a && b)
answer(1);
else if(!a && !b)
answer(1);
else if(a && !b)
answer(1 + ask(x,other[1]));
else if(!a && b)
answer(1 + ask(y,other[0]));
return;
}
signed main()
{
#ifdef NICEGUODONG
// freopen("data.in","r",stdin);
#endif
int T;
ios::sync_with_stdio(false);
cin >> T;
while(T--){
int flag = 0;
cin >> n;
for(int i = 1; i <= n; i += 2){
int x = i;
int y = i + 1;
if(ask(x,y)){
check(x,y);
flag = 1;
break;
}
}
if(!flag){
check(n,1);
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3604kb
input:
2 4 1 0 0 4 0 1 1 0 1
output:
? 1 2 ? 1 3 ? 2 4 ! 1 ? 1 2 ? 3 4 ? 3 1 ? 4 2 ? 3 2 ! 2
result:
ok Correct (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3604kb
input:
87 13 0 0 0 0 0 1 0 1 1 15 0 0 0 0 0 0 1 1 0 1 7 0 0 0
output:
? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 11 1 ? 12 2 ? 12 1 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 13 14 ? 13 1 ? 14 2 ? 13 2 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 7 8
result:
wrong answer Integer 8 violates the range [1, 7] (test case 3)