QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#378431 | #6394. Turn on the Light | langod | WA | 0ms | 3596kb | C++14 | 884b | 2024-04-06 12:55:03 | 2024-04-06 12:55:03 |
Judging History
answer
// Created by qyy on 2024/4/6.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3f;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
int lastans, n, a[N];
void solve() {
cin >> n;
lastans = 0;
int newans = 0;
int l = 1, r = n;
while(l <= r){
int mid = (l + r) >> 1;
cout << "? " << mid << endl;
cin >> newans;
if(newans == lastans){
cout << "! " << mid << endl;
return ;
}else if(newans > lastans){
l = mid + 1;
lastans = newans;
}else{
r = mid - 1;
lastans = newans;
}
}
}
signed main() {
// ios::sync_with_stdio(false);
// cin.tie(0);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
3 1 1
output:
? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3596kb
input:
10 1 2 3 4
output:
? 5 ? 8 ? 9 ? 10
result:
wrong answer format Unexpected end of file - token expected