QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#605161 | #6394. Turn on the Light | lqh2024# | WA | 1ms | 3844kb | C++17 | 1.7kb | 2024-10-02 15:53:49 | 2024-10-02 15:53:49 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define int long long
using i64 = long long;
mt19937_64 rd(time(0));
template <class K, class C = less<>> using paring_heap = __gnu_pbds::priority_queue<K, C>;
template <class K> using rb_tree = tree<K, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T, class ... A> void debug(const T & t, const A & ... a) { cerr << "[" << t, ((cerr << ", " << a), ...), cerr << "]\n"; }
const i64 mod = [](bool n) { return n ? 998244353 : 1e9 + 7; } (1);
void QAQ() {
int n;
cin >> n;
int l = 1, r = n;
auto query = [&](int x) {
cout << "? " << x << endl;
cin >> x;
return x;
};
auto print = [&](int x) {
cout << "! " << x << endl;
return -1;
};
int lst = 0, now = 0;
while (l < r) {
int m = l + r >> 1;
auto chk = [&](int m) {
now = query(m);
int tmp = now;
if (now == abs(lst)) {
return print(m);
}
now = query(r);
if (now == tmp) {
return print(r);
} else if (now == lst) {
r--;
l = m + 1;
} else {
r = m - 1;
}
return 0;
};
if (chk(m) == -1) {
return;
}
}
print(l);
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
int t = 1;
// cin >> t;
for (cout << fixed << setprecision(12); t--; QAQ());
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3652kb
input:
3 1 1
output:
? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
10 1 0 1 0
output:
? 5 ? 10 ? 7 ? 9 ! 8
result:
ok Correct position at 8
Test #3:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
9 1 2 1 1
output:
? 5 ? 9 ? 2 ? 4 ! 4
result:
ok Correct position at 4
Test #4:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
8 1 0 1 1
output:
? 4 ? 8 ? 6 ? 7 ! 7
result:
ok Correct position at 7
Test #5:
score: 0
Accepted
time: 1ms
memory: 3688kb
input:
7 1 2 3 4
output:
? 4 ? 7 ? 2 ? 3 ! 1
result:
ok Correct position at 1
Test #6:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
6 1 0 1 1
output:
? 3 ? 6 ? 4 ? 5 ! 5
result:
ok Correct position at 5
Test #7:
score: 0
Accepted
time: 1ms
memory: 3788kb
input:
5 1 2 2 3
output:
? 3 ? 5 ? 1 ? 2 ! 1
result:
ok Correct position at 1
Test #8:
score: 0
Accepted
time: 1ms
memory: 3844kb
input:
4 1 1
output:
? 2 ? 4 ! 4
result:
ok Correct position at 4
Test #9:
score: 0
Accepted
time: 1ms
memory: 3792kb
input:
3 1 1
output:
? 2 ? 3 ! 3
result:
ok Correct position at 3
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: 0ms
memory: 3764kb
input:
1
output:
! 1
result:
ok Correct position at 1
Test #12:
score: -100
Wrong Answer
time: 0ms
memory: 3652kb
input:
1000000 1 0 1 2 3 4 3 4 3 2 1 0 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
output:
? 500000 ? 1000000 ? 750000 ? 999999 ? 625000 ? 749999 ? 562500 ? 624999 ? 531250 ? 562499 ? 515625 ? 531249 ? 523437 ? 531248 ? 519531 ? 523436 ? 517578 ? 519530 ? 516601 ? 517577 ? 516113 ? 516600 ? 515869 ? 516112 ? 515747 ? 515868 ? 515686 ? 515746 ? 515655 ? 515685 ? 515640 ? 515654 ? 515632 ? ...
result:
wrong answer Wrong answer, more than 1 possible light!