QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#371546 | #6394. Turn on the Light | HosamaJJF | WA | 1ms | 3660kb | C++17 | 768b | 2024-03-30 13:54:23 | 2024-03-30 13:54:24 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n, x, xx;
int main()
{
cin >> n;
cout << "? 1\n";
cout.flush();
cin >> x;
if (x == 0)
{
cout << "! 1\n";
cout.flush();
return 0;
}
int t = 40, l = 2, r = n;
while (l <= r)
{
int mid = (l + r) >> 1;
cout << "? " << mid << "\n";
cout.flush();
cin >> xx;
// cout<<"- "<<xx<<"\n";
if (xx < x)
{
r = mid - 1;
}
else if (xx > x)
{
l = mid + 1;
}
else
{
cout << "! " << mid << "\n";
cout.flush();
break;
}
x = xx;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3644kb
input:
3 1 2 2
output:
? 1 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3660kb
input:
10 1 0 1 2 3
output:
? 1 ? 6 ? 3 ? 4 ? 5
result:
wrong answer format Unexpected end of file - token expected