QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#417670 | #8719. 后继 | fallleaves01# | WA | 1ms | 3744kb | C++20 | 1.2kb | 2024-05-22 20:36:29 | 2024-05-22 20:36:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int n, m;
cin >> n >> m;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 0; i < m; i++) {
int x = 0;
vector<pair<int, int>> p = {pair{1, n}};
for (int i = 29; i >= 0; i--) {
pair<int, int> dv = {-1, -1};
for (auto [l, r] : p) {
if ((a[l] ^ a[r]) & (1 << i)) {
dv = {l, r};
}
}
if (dv.first == -1) {
continue;
}
for (int j = dv.first; j < dv.second; j++) {
if (a[j + 1] & (1 << i)) {
cout << "? " << j + 1 << endl;
int res;
cin >> res;
if (res >= dv.first && res <= j) {
x ^= 1 << i;
}
break;
}
}
auto tmp = p;
p.clear();
for (auto [l, r] : tmp) {
int d = -1;
for (int j = l; j < r; j++) {
if (a[j + 1] & (1 << i)) {
d = j;
break;
}
}
if (d != -1) {
p.emplace_back(l, d);
p.emplace_back(d + 1, r);
} else {
p.emplace_back(l, r);
}
}
}
cout << "! " << x << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3492kb
input:
5 1 1 2 3 4 5 -1 1 4
output:
? 4 ? 2 ? 5 ! 3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3456kb
input:
1 1 0
output:
! 0
result:
ok 1 number(s): "0"
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3744kb
input:
10 10 380864879 387438357 21484978 21099484 375657510 23189485 24467021 379687119 386094773 15156199 9 1 2 4 7 6 3 9 7 5 4 -1 6 3 9 1 3 10 -1 6 7 9 2 5 -1 3 6 7 9 -1 5 4 2 6 3 9 -1 5 4 2 6 3 8 4 1 7 -1 10 3 9 2 5 -1 3 6 7 10 8 1 7 3 -1 6 -1 9 1 7 6 4 3
output:
? 2 ? 5 ? 8 ? 6 ? 10 ? 7 ? 4 ! 1056768 ? 2 ? 5 ? 8 ? 6 ? 10 ? 7 ? 4 ! 34611200 ? 2 ? 5 ? 8 ? 6 ? 10 ? 7 ? 4 ! 1048576 ? 2 ? 5 ? 8 ? 6 ? 10 ? 7 ? 4 ! 101711872 ? 2 ? 5 ? 8 ? 6 ? 10 ? 7 ? 4 ! 34611200 ? 2 ? 5 ? 8 ? 6 ? 10 ? 7 ? 4 ! 34611200 ? 2 ? 5 ? 8 ? 6 ? 10 ? 7 ? 4 ! 67117056 ? 2 ? 5 ? 8 ? 6 ? 10 ...
result:
wrong answer 1st numbers differ - expected: '271581184', found: '1056768'