QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#613324 | #6394. Turn on the Light | liaoyingyu | WA | 1ms | 3684kb | C++17 | 615b | 2024-10-05 13:55:23 | 2024-10-05 13:56:28 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
int s = 0;
int pre = 0;
void beizeng(int start, int end) {
int now = 1;
int shuru;
while (1) {
if (now > end) {
s += now / 2;
beizeng(now / 2+1, end);
return;
}
cout << '?' << ' ' << s+now << endl;
cin >> shuru;
if (shuru == pre) {
cout << '!' << ' ' << s+now << endl;
return;
}
else if (shuru > pre) {
pre = shuru;
now *= 2;
}
else {
s += now / 2;
pre = shuru;
beizeng(now / 2+1, now-1);
return;
}
}
}
signed main() {
int n;
cin >> n;
beizeng(1, n);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
input:
3 1 2 2
output:
? 1 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
10 1 2 3 2 3 3
output:
? 1 ? 2 ? 4 ? 8 ? 5 ? 6 ! 6
result:
ok Correct position at 6
Test #3:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
9 1 2 3 2 3 3
output:
? 1 ? 2 ? 4 ? 8 ? 5 ? 6 ! 6
result:
ok Correct position at 6
Test #4:
score: 0
Accepted
time: 1ms
memory: 3596kb
input:
8 1 2 3 2 3 3
output:
? 1 ? 2 ? 4 ? 8 ? 5 ? 6 ! 6
result:
ok Correct position at 6
Test #5:
score: -100
Wrong Answer
time: 1ms
memory: 3592kb
input:
7 1 2 3 4 5
output:
? 1 ? 2 ? 4 ? 5 ? 6 ? 8
result:
wrong answer Integer parameter [name=x] equals to 8, violates the range [1, 7]