QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#252803 | #6394. Turn on the Light | supepapupu | WA | 0ms | 3376kb | C++17 | 1.0kb | 2023-11-16 11:25:30 | 2023-11-16 11:25:31 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
#define el '\n'
#define debug(x) cout << #x << ": " << x << el
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 5010, INF = 0x3f3f3f3f, mod = 998244353;
void inc(ll &a, ll b) {
a += b;
if (a >= mod) a -= mod;
}
void dec(ll &a, ll b) {
a -= b;
if (a < 0) a += mod;
}
ll add(ll a, ll b) {
a += b;
return a >= mod ? a - mod : a;
}
ll del(ll a, ll b) {
a -= b;
return a < 0 ? a + mod : a;
}
int main() {
// ios::sync_with_stdio(0); cin.tie(0);
int n; cin >> n;
int l = 1, r = n, mid, last = 0;
while (l < r) {
mid = l + r >> 1;
cout << "? " << mid << endl;
int now; cin >> now;
if (now == last) {
cout << "! " << mid << endl;
return 0;
}
if (now > last) l = mid + 1;
else r = mid - 1;
last = now;
}
cout << "! " << l << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3376kb
input:
3 1
output:
? 2 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3376kb
input:
10 1 2 3
output:
? 5 ? 8 ? 9 ! 10
result:
wrong answer Wrong answer, more than 1 possible light!