QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#126832 | #6394. Turn on the Light | UNos_maricones# | WA | 2ms | 3588kb | C++20 | 1.2kb | 2023-07-19 04:10:24 | 2023-07-19 04:10:27 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std ;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> ii;
typedef long double lf;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll SQ = 320;
const ll N = 3e5+5;
const ll mod = 998244353;
const ll oo = 1e9+5;
int ask (int x) {
cout << "? " << x << endl;
cin >> x;
return x;
}
int main(){
#ifdef LOCAL
// freopen("input.txt","r",stdin);
#endif // LOCAL
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n; cin >> n;
int l = 1, r = n;
if (ask(1) == 0) {
cout << "! " << 1 << endl;
return 0;
}
while (l < r) {
int mi = (l + r) / 2;
int g = ask(mi);
if (g == 0) {
l++;
r = mi - 1;
if (ask(l) == 0) {
cout << "! " << l << endl;
return 0;
}
}
else if (g == 2) {
l = mi;
if (ask(r) == 2) {
cout << "! " << r << endl;
return 0;
}
r--;
}
else {
cout << "! " << mi << endl;
return 0;
}
}
cout << "! " << l << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3588kb
input:
3 1 2 2
output:
? 1 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: 0
Accepted
time: 1ms
memory: 3420kb
input:
10 1 2 1 2 2
output:
? 1 ? 5 ? 10 ? 7 ? 9 ! 9
result:
ok Correct position at 9
Test #3:
score: 0
Accepted
time: 1ms
memory: 3516kb
input:
9 1 2 1 2 2
output:
? 1 ? 5 ? 9 ? 6 ? 8 ! 8
result:
ok Correct position at 8
Test #4:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
8 1 2 1 2 2
output:
? 1 ? 4 ? 8 ? 5 ? 7 ! 7
result:
ok Correct position at 7
Test #5:
score: 0
Accepted
time: 2ms
memory: 3416kb
input:
7 1 2 1 1
output:
? 1 ? 4 ? 7 ? 5 ! 5
result:
ok Correct position at 5
Test #6:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
6 1 2 1 1
output:
? 1 ? 3 ? 6 ? 4 ! 4
result:
ok Correct position at 4
Test #7:
score: 0
Accepted
time: 1ms
memory: 3396kb
input:
5 1 2 2
output:
? 1 ? 3 ? 5 ! 5
result:
ok Correct position at 5
Test #8:
score: 0
Accepted
time: 2ms
memory: 3424kb
input:
4 1 2 2
output:
? 1 ? 2 ? 4 ! 4
result:
ok Correct position at 4
Test #9:
score: 0
Accepted
time: 2ms
memory: 3420kb
input:
3 1 1
output:
? 1 ? 2 ! 2
result:
ok Correct position at 2
Test #10:
score: -100
Wrong Answer
time: 1ms
memory: 3588kb
input:
2 1 1
output:
? 1 ? 1 ! 1
result:
wrong answer Wrong favorite light!