QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#594112 | #6303. Inversion | shiqiaqiaya# | WA | 74ms | 3688kb | C++20 | 1.1kb | 2024-09-27 19:18:15 | 2024-09-27 19:18:16 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> a;
a.push_back(1);
auto ask = [&](int l, int r) -> int {
if (l == r) return 0;
cout << "? " << l << " " << r << endl;
int x;
cin >> x;
return x;
};
auto compare = [&](int x, int y) -> bool {
int a = ask(x, y - 1);
int b = ask(x + 1, y);
int c = ask(x, y);
if ((a + b + c) % 2 == 0) return false;
return true;
};
for (int i = 2; i <= n; i++) {
int L = 0, R = a.size() - 1, res = -1;
while (L <= R) {
int mid = (L + R) / 2;
if (!compare(a[mid], i)) {
res = mid;
L = mid + 1;
} else {
R = mid - 1;
}
}
a.insert(a.begin() + res + 1, i);
}
vector<int> ans(n + 1);
for (int i = 0; i < n; i++) {
ans[a[i]] = i + 1;
}
cout << "! ";
for (int i = 1; i <= n; i++) {
cout << ans[i] << " ";
}
cout << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3584kb
input:
3 0 0 1 0
output:
? 1 2 ? 1 2 ? 2 3 ? 1 3 ! 2 3 1
result:
ok OK, guesses=4
Test #2:
score: -100
Wrong Answer
time: 74ms
memory: 3688kb
input:
1993 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 1 0 1 0 1 0 1 0 0 0 1 0 0 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 1 0 0 1 1 1 0 1 1 1 0 1 1 0 1 1 0 0 1 0 1 1 1 1 0 0 1 0 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 1 0 1 0 0 1 1 0 0 1 0...
output:
? 1 2 ? 1 2 ? 2 3 ? 1 3 ? 2 3 ? 2 3 ? 3 4 ? 2 4 ? 3 4 ? 2 4 ? 3 5 ? 2 5 ? 1 4 ? 2 5 ? 1 5 ? 2 5 ? 3 6 ? 2 6 ? 5 6 ? 1 5 ? 2 6 ? 1 6 ? 6 7 ? 5 6 ? 6 7 ? 5 7 ? 6 7 ? 7 8 ? 6 8 ? 3 7 ? 4 8 ? 3 8 ? 4 7 ? 5 8 ? 4 8 ? 6 8 ? 7 9 ? 6 9 ? 3 8 ? 4 9 ? 3 9 ? 2 8 ? 3 9 ? 2 9 ? 9 10 ? 5 9 ? 6 10 ? 5 10 ? 7 9 ? 8...
result:
wrong output format Unexpected end of file - int32 expected