QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#397129 | #6394. Turn on the Light | s | WA | 1ms | 3808kb | C++14 | 1.2kb | 2024-04-23 17:12:02 | 2024-04-23 17:12:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
// #define double long double
const int N = 1e6 + 10;
const int M = 4e5 + 10;
const int mod = 998244353;
const int inf = 1e18;
typedef long long ll;
typedef pair<int, int> pii;
typedef array<int, 3> ary;
#define PI acos(-1)
// #define endl '\n'
#define pb push_back
mt19937 rnd(time(0));
#define xx first
#define yy second
#define IOS ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int l, r, n, x;
int as = 0;
void query(int x)
{
cout << "? " << x << endl;
}
void solve()
{
cin >> n;
cout << "? 1" << endl;
cin >> x;
if (x == 0)
{
cout << "! 1" << endl;
return;
}
as = 1;
l = 2, r = n;
while (l < r)
{
int mid = (l + r) >> 1;
query(mid);
cin >> x;
if (x == as)
{
cout << "! " << mid << endl;
return;
}
if (x > as)
{
l = mid + 1;
}
else
{
r = mid;
}
as = x;
}
cout << "! " << l << endl;
}
signed main()
{
IOS int _ = 1;
// cin>>_;
while (_--)
{
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3808kb
input:
3 1 2
output:
? 1 ? 2 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3728kb
input:
10 1 0 1 2
output:
? 1 ? 6 ? 4 ? 5 ! 6
result:
wrong answer Wrong answer, more than 1 possible light!