QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#668485 | #8239. Mysterious Tree | Credit | WA | 1ms | 3560kb | C++17 | 1.4kb | 2024-10-23 14:37:11 | 2024-10-23 14:37:12 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[300005],sum[300005];
ll n;
char ch;
void solve(){
ll x,y;
cin >> n;
for(int i = 1;i <= n;i+=2){
cout << "? " << i << " " << (i+1)%(n+1) + bool(i==n) << "\n";
cout.flush();
cin >> ch;
if(ch == '1'){
x = i;
cout << "? " << x << " " << (x+2)%(n +1) + bool(x >= n - 1) << "\n";
cout.flush();
char ch1,ch2,ch3;
cin >> ch1;
cout << "? " << x << " " << (x+3)%(n+1) + bool(x >= n - 2) << "\n";
cout.flush();
cin >> ch2;
if(ch1 == '1'&&ch2 == '1'){
cout << "! 2\n";
return ;
}
x = x+1;
cout << "? " << x << " " << (x+1)%(n+1) + bool(x >= n ) << "\n";
cout.flush();
cin >> ch1;
cout << "? " << x << " " << (x+2)%(n+1) + bool(x >= n - 1) << "\n";
cout.flush();
cin >> ch2;
if(ch1 == '1'&&ch2 == '1'){
cout << "! 2\n";
return ;
}
cout << "! 1\n";
return;
}
}
cout << "! 1\n";
}
signed main(){
// ios::sync_with_stdio(false);
// cin.tie(0);
// cout.tie(0);
int t = 1;
cin >> t;
while(t--){
solve();
}
return 0;
}
/*
*/
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3560kb
input:
2 4 1 0 0 1 0 4 0 1 1 1
output:
? 1 2 ? 1 3 ? 1 4 ? 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: 0ms
memory: 3560kb
input:
87 13 0 0 0 0 0 1 0 0 1 1 15 0 0 0 0 0 0 1 1 1 7 0 0 0 1 1 1 15 0 0 0 1 0 0 0 0 19 0 0 0 0 0 1 1 1 20 0 0 0 0 0 0 0 0 0 0 7 0 0 1 0 0 1 1 20 0 0 0 0 0 0 0 1 1 1 17 0 0 0 0 0 0 0 0 0 11 1 0 0 0 1 14 0 0 0 0 0 0 0 13 0 0 0 0 0 0 0 18 0 0 0 0 0 1 0 0 1 1 14 0 1 0 0 1 1 20 0 0 0 0 1 0 0 0 0 11 0 0 0 1 0...
output:
? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 11 13 ? 11 1 ? 12 13 ? 12 1 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 13 14 ? 13 15 ? 13 1 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 7 1 ? 7 2 ? 7 3 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 7 9 ? 7 10 ? 8 9 ? 8 10 ! 1 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 11 13 ? 11 14 ! 2 ? 1 2 ? ...
result:
wrong answer Too many queries , n = 8 , now_q 8 (test case 32)