QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#460657 | #8239. Mysterious Tree | CRN2010 | WA | 3ms | 3592kb | C++20 | 2.9kb | 2024-07-01 23:47:03 | 2024-07-01 23:47:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std ;
void solve() {
int n , op ;
cin >> n ;
for(int i = 2 ; i <= n ; i += 2)
{
cout << "? " << i << ' ' << i - 1 << endl ;
cin >> op ;
if (op)
{
if ( i == n ) {
cout << "? " << 1 << ' ' << i << endl ;
cin >> op ;
if ( op ) {
cout << "? " << 2 << ' ' << i << endl ;
cin >> op ;
if ( op ) {
cout << "! 2" << endl ;
return ;
} else {
cout << "! 1" << endl ;
return ;
}
} else {
cout << "? " << 1 << ' ' << i - 1 << endl ;
cin >> op ;
if ( op ) {
cout << "? " << 2 << ' ' << i - 1 << endl ;
cin >> op ;
if ( op ) {
cout << "! 2" << endl ;
return ;
} else {
cout << "! 1" << endl ;
return ;
}
} else {
cout << "! 1" << endl ;
return ;
}
}
} else {
cout << "? " << i << ' ' << n << endl ;
cin >> op ;
if ( op ) {
if ( i == n - 1 ) {
cout << "? " << 1 << ' ' << i << endl ;
cin >> op ;
if ( op ) {
cout << "! 2" << endl ;
return ;
} else {
cout << "! 1" << endl ;
return ;
}
} else {
cout << "? " << i << ' ' << n - 1 << endl ;
cin >> op ;
if ( op ) {
cout << "! 2" << endl ;
return ;
} else {
cout << "! 1" << endl ;
return ;
}
}
} else {
cout << "? " << i - 1 << ' ' << n << endl ;
cin >> op ;
if ( op ) {
if ( i == n - 1 ) {
cout << "? " << 1 << ' ' << i - 1 << endl ;
cin >> op ;
if ( op ) {
cout << "! 2" << endl ;
return ;
} else {
cout << "! 1" << endl ;
return ;
}
} else {
cout << "? " << i - 1 << ' ' << n - 1 << endl ;
cin >> op ;
if ( op ) {
cout << "! 2" << endl ;
return ;
} else {
cout << "! 1" << endl ;
return ;
}
}
} else {
cout << "! 1" << endl ;
return ;
}
}
}
}
}
if ( n & 1 ) {
cout << "? " << n - 1 << ' ' << n << endl ;
cin >> op ;
cout << "? " << 1 << ' ' << n << endl ;
cin >> op ;
if ( op ) {
cout << "? " << 2 << ' ' << n << endl ;
cin >> op ;
if ( op ) {
cout << "! 2" << endl ;
return ;
} else {
cout << "! 1" << endl ;
return ;
}
} else {
cout << "? " << 1 << ' ' << n - 1 << endl ;
cin >> op ;
if (op) {
cout << "? " << 2 << ' ' << n - 1 << endl ;
cin >> op ;
if ( op ) {
cout << "! 2" << endl ;
return ;
} else {
cout << "! 1" << endl ;
return ;
}
} else {
cout << "! 1" << endl ;
return ;
}
}
}
cout << "! 1" << endl ;
}
int main()
{
int t ;
cin >> t ;
while (t--)
{
solve() ;
}
return 0 ;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3592kb
input:
2 4 1 0 0 4 0 1 0 1 1
output:
? 2 1 ? 2 4 ? 1 4 ! 1 ? 2 1 ? 4 3 ? 1 4 ? 1 3 ? 2 3 ! 2
result:
ok Correct (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 3592kb
input:
87 13 0 0 0 0 0 1 1 1 15 0 0 0 0 0 0 1 0 1 1 7 0 0 0 1 1 1 15 0 0 0 1 1 0 19 0 0 0 0 0 1 0 1 1 20 0 0 0 0 0 0 0 0 0 0 7 0 0 1 1 1 20 0 0 0 0 0 0 0 1 0 1 1 17 0 0 0 0 0 0 0 0 0 0 1 0 11 1 0 0 14 0 0 0 0 0 0 0 13 0 0 0 0 0 0 0 0 0 18 0 0 0 0 0 1 1 1 14 0 1 1 1 20 0 0 0 0 1 0 0 11 0 0 0 1 0 0 11 0 1 1 ...
output:
? 2 1 ? 4 3 ? 6 5 ? 8 7 ? 10 9 ? 12 11 ? 12 13 ? 1 12 ! 2 ? 2 1 ? 4 3 ? 6 5 ? 8 7 ? 10 9 ? 12 11 ? 14 13 ? 14 15 ? 13 15 ? 1 13 ! 2 ? 2 1 ? 4 3 ? 6 5 ? 6 7 ? 1 7 ? 2 7 ! 2 ? 2 1 ? 4 3 ? 6 5 ? 8 7 ? 8 15 ? 8 14 ! 1 ? 2 1 ? 4 3 ? 6 5 ? 8 7 ? 10 9 ? 12 11 ? 12 19 ? 11 19 ? 11 18 ! 2 ? 2 1 ? 4 3 ? 6 5 ?...
result:
wrong answer Wrong prediction (test case 55)