QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#588885 | #6394. Turn on the Light | yumingsk# | WA | 1ms | 3708kb | C++14 | 1.5kb | 2024-09-25 15:03:39 | 2024-09-25 15:03:41 |
Judging History
answer
#pragma GCC optimize(3, "Ofast", "inline")
#include <iostream>
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define INF 0x3f3f3f3f
#define L_INF 0x7f3f3f3f3f3f3f3f
#define db cout << "debug\n";
using namespace std;
const int Mod = 998244353;
using ll = long long;
int fh = 0;
int print(int x)
{
cout << "? " << x << endl;
int c;
cin >> c;
return c - fh;
}
int f(int l, int r)
{
// cout << l << ' ' << r << '\n';
if (l == r)
return l;
int num = 0;
int ttt = 1;
int i;
int nxt;
for (i = l; i <= r; i += ttt)
{
ttt *= 2;
// cout << l << ' ' << r << ' ' << i << ' ' << ttt << '\n';
nxt = print(i);
// cout << nxt << ' ' << fh << '\n';
num++;
if (nxt == num)
continue;
else if (nxt == num - 1)
return i;
else
{
fh = nxt;
// cout << "F" << fh << '\n';
if (i - ttt / 2 + 1 <= i - 1)
return f(i - ttt / 2 + 1, i - 1);
}
}
// cout << i << ' ' << ttt << '\n';
// if (i - ttt + 1 <= r)
if (i - ttt + 1 <= r)
{
fh = nxt;
return f(i - ttt + 1, r);
}
}
void solve()
{
int n;
cin >> n;
int res = f(1, n);
cout << "! " << res << endl;
}
int main()
{
// IOS;
int t = 1;
// cin >> t;
while (t--)
{
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3536kb
input:
3 1 1
output:
? 1 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
10 1 2 3 4 4
output:
? 1 ? 3 ? 7 ? 8 ? 10 ! 10
result:
ok Correct position at 10
Test #3:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
9 1 2 1 2 2
output:
? 1 ? 3 ? 7 ? 4 ? 6 ! 6
result:
ok Correct position at 6
Test #4:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
8 1 2 1 2 2
output:
? 1 ? 3 ? 7 ? 4 ? 6 ! 6
result:
ok Correct position at 6
Test #5:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
7 1 2 1 2 2
output:
? 1 ? 3 ? 7 ? 4 ? 6 ! 6
result:
ok Correct position at 6
Test #6:
score: 0
Accepted
time: 1ms
memory: 3576kb
input:
6 1 2 3 2
output:
? 1 ? 3 ? 4 ? 6 ! 5
result:
ok Correct position at 5
Test #7:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
5 1 2 3
output:
? 1 ? 3 ? 4 ! 5
result:
ok Correct position at 5
Test #8:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
4 1 1
output:
? 1 ? 3 ! 3
result:
ok Correct position at 3
Test #9:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
3 1 0
output:
? 1 ? 3 ! 2
result:
ok Correct position at 2
Test #10:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
2 1
output:
? 1 ! 2
result:
ok Correct position at 2
Test #11:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
1
output:
! 1
result:
ok Correct position at 1
Test #12:
score: -100
Wrong Answer
time: 0ms
memory: 3652kb
input:
1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
output:
? 1 ? 3 ? 7 ? 15 ? 31 ? 63 ? 127 ? 255 ? 511 ? 1023 ? 2047 ? 4095 ? 8191 ? 16383 ? 32767 ? 65535 ? 131071 ? 262143 ? 524287 ? 524288 ? 524290 ? 524294 ? 524302 ? 524318 ? 524350 ? 524414 ? 524542 ? 524798 ? 525310 ? 526334 ? 528382 ? 532478 ? 540670 ? 557054 ? 589822 ? 655358 ? 786430 ? 786431 ? 786...
result:
wrong answer Wrong answer, more than 1 possible light!