QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#621432 | #6394. Turn on the Light | 666ldc# | WA | 1ms | 3716kb | C++17 | 1.2kb | 2024-10-08 14:29:19 | 2024-10-08 14:29:36 |
Judging History
answer
#pragma GCC optimize(2)
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define int long long
// #define endl '\n'
using i128 = __int128;
using i64 = long long;
using f128 = long double;
using u64 = unsigned long long;
using pii = pair<int, int>;
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;
const i64 inf = 2e18;
//-------------------------------------------
void solve()
{
int n;
cin >> n;
int l = 1, r = n;
int ct = 0;
auto check = [&](int x)
{
int t;
cout << "? " << x << endl;
cin >> t;
if (ct < t)
{
ct = t;
return true;
}
else if (ct >= t)
{
ct = t;
return false;
}
};
while (r > l)
{
int mid = l + r >> 1;
if (check(mid))
l = mid + 1;
else
r = mid;
}
cout << "! " << r << endl;
}
signed main()
{
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// cout.tie(nullptr);
int T = 1;
// cin >> T;
for (int i = 1; i <= T; i++)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3716kb
input:
3 1
output:
? 2 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3656kb
input:
10 1 2 3
output:
? 5 ? 8 ? 9 ! 10
result:
wrong answer Wrong answer, more than 1 possible light!