QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#397577 | #6394. Turn on the Light | ryh7# | WA | 1ms | 3700kb | C++17 | 768b | 2024-04-24 13:31:55 | 2024-04-24 13:31:55 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef unsigned long long ull;
int n,val;
int main() {
cin>>n;
int left = 1 , right = n;
while(left < right){
int mid = (left + right) >> 1;
cout<<("? ")<<mid<<"\n";
cout.flush();
// s.insert(mid);
int t;
cin>>t;
if(t > val){
left = mid + 1;
}else if(t < val){
right = mid - 1;
}else if(t == val){
cout<<"! "<<mid<<'\n';
cout.flush();
return 0;
}
val = t;
}
cout<<"! "<<left<<'\n';
cout.flush();
return 0;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3620kb
input:
3 1
output:
? 2 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3700kb
input:
10 1 2 3
output:
? 5 ? 8 ? 9 ! 10
result:
wrong answer Wrong answer, more than 1 possible light!