QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#601915 | #6401. Classic: N Real DNA Pots | 0x3ea# | WA | 0ms | 3540kb | C++17 | 1.1kb | 2024-09-30 15:50:57 | 2024-09-30 15:50:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
void solve()
{
int n;
cin >> n;
int rec = 0;
auto q = [&](int x) -> int
{
cout << "? " << x << endl;
int res;
cin >> res;
return res;
};
int l = 1, r = n, pre = 0;
while (l < r)
{
int mid = (l + r + 1) >> 1;
int rec = q(l);
if (pre == rec)
{
cout << "! " << l << endl;
return;
}
int res = q(mid);
if (res == rec)
{
cout << "! " << mid << endl;
return;
}
if (res == pre)
{
l = l + 1, r = mid - 1;
}
else
{
l = mid + 1;
}
pre = res;
// cout << l << " " << r << endl;
}
cout << "! " << l << endl;
}
int main()
{
// #ifdef x3ea
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
// #endif
// ios::sync_with_stdio(false);
// cin.tie(0), cout.tie(0);
int _ = 1;
// cin >> _;
while (_--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3540kb
input:
4 3 1 2 2 4 3 3 4 1
output:
? 1 ? 3 ! 4
result:
wrong output format Expected double, but "?" found