QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#470373 | #6394. Turn on the Light | UESTC_DECAYALI# | RE | 1ms | 3840kb | C++17 | 757b | 2024-07-10 12:21:46 | 2024-07-10 12:21:47 |
Judging History
answer
#include <bits/stdc++.h>
int query(int x) {
static int pre = 0;
std::cout << "? " << x + 1 << std::endl;
int res; std::cin >> res;
if(res == pre) return std::cout << "! " << x + 1 << std::endl, exit(0), 0;
return pre = res;
}
int main() {
std::ios::sync_with_stdio(false);
int n; std::cin >> n;
int pre = 0;
std::vector<int> a(n), b;
for(int i = 0; i < n; ++i) a[i] = i;
for(;;) {
int l = a.size() / 4, r = a.size() * 3 / 4;
int q = (query(a[l]), query(a[r]));
b.clear();
if(q == pre) {
for(int i = l + 1; i < r; ++i) b.push_back(a[i]);
} else {
for(int i = 0; i < l; ++i) b.push_back(a[i]);
for(int i = r + 1; i < n; ++i) b.push_back(a[i]);
}
std::swap(a, b);
pre = q;
}
return -1;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3620kb
input:
3 1 1
output:
? 1 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
10 1 0 1 0 0
output:
? 3 ? 8 ? 5 ? 7 ? 6 ! 6
result:
ok Correct position at 6
Test #3:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
9 1 2 3 2 2
output:
? 3 ? 7 ? 2 ? 9 ? 8 ! 8
result:
ok Correct position at 8
Test #4:
score: 0
Accepted
time: 1ms
memory: 3508kb
input:
8 1 0 1 0 0
output:
? 3 ? 7 ? 4 ? 6 ? 5 ! 5
result:
ok Correct position at 5
Test #5:
score: 0
Accepted
time: 1ms
memory: 3588kb
input:
7 1 0 1 0 0
output:
? 2 ? 6 ? 3 ? 5 ? 4 ! 4
result:
ok Correct position at 4
Test #6:
score: 0
Accepted
time: 1ms
memory: 3532kb
input:
6 1 0 1 1
output:
? 2 ? 5 ? 3 ? 4 ! 4
result:
ok Correct position at 4
Test #7:
score: 0
Accepted
time: 1ms
memory: 3624kb
input:
5 1 2 3 3
output:
? 2 ? 4 ? 1 ? 5 ! 5
result:
ok Correct position at 5
Test #8:
score: 0
Accepted
time: 1ms
memory: 3560kb
input:
4 1 1
output:
? 2 ? 4 ! 4
result:
ok Correct position at 4
Test #9:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
3 1 0 0
output:
? 1 ? 3 ? 2 ! 2
result:
ok Correct position at 2
Test #10:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
2 1 1
output:
? 1 ? 2 ! 2
result:
ok Correct position at 2
Test #11:
score: 0
Accepted
time: 1ms
memory: 3616kb
input:
1 0
output:
? 1 ! 1
result:
ok Correct position at 1
Test #12:
score: -100
Runtime Error
input:
1000000 1 0 1 0 1 0 1 0 1 0 1 2
output:
? 250001 ? 750001 ? 375001 ? 625001 ? 437501 ? 562501 ? 468751 ? 531251 ? 484376 ? 515626 ? 492189 ? 507813