QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#594273 | #6303. Inversion | shiqiaqiaya# | WA | 68ms | 34256kb | C++20 | 1.7kb | 2024-09-27 20:50:54 | 2024-09-27 20:50:54 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
mt19937 rnd(time(0));
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
// int t = 0;
// for (int i = 1; i <= 2000; i++) {
// t += log2(i) * 2;
// }
// cout << t << "\n";
int n;
cin >> n;
vector<int> a;
a.push_back(1);
vector vis(n + 1, vector<int> (n + 1, -1));
auto ask = [&](int l, int r) -> int {
if (l >= r) return 0;
if (vis[l][r] != -1) return vis[l][r];
cout << "? " << l << " " << r << endl;
int x;
cin >> x;
return vis[l][r] = 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);
int d = ask(x + 1, y - 1);
if ((a + b + c - d + 2) % 2 == 0) return false;
return true;
};
auto cp = [&](int x, int y) -> bool {
int a = ask(x, x + 1);
int b = ask(x + 1, y);
if ((a + b) % 2 == 0) return false;
return true;
};
vector<int> p;
for (int i = n; i >= 2; i--) {
p.push_back(i);
}
random_shuffle(p.begin(), p.end());
for (int i : p) {
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] << " \n"[i == n];
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3820kb
input:
3 0 1 0
output:
? 1 2 ? 2 3 ? 1 3 ! 2 3 1
result:
ok OK, guesses=3
Test #2:
score: -100
Wrong Answer
time: 68ms
memory: 34256kb
input:
1993 1 1 0 1 0 0 0 1 0 0 1 1 1 0 1 0 0 0 0 0 0 1 1 1 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 1 0 1 1 1 0 1 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 1 1 0 1 1 0 1 0 0 0 1 1 0 0 0 0 0 0 1 0 1 1 1 1 0 0 0 1 1 1 1 0 1 1 1 0 1 1 1 0 0 1 1 0 0 1 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 1 1 1 0 0 0...
output:
? 1 788 ? 2 789 ? 1 789 ? 2 788 ? 789 802 ? 790 803 ? 789 803 ? 790 802 ? 789 1291 ? 790 1292 ? 789 1292 ? 790 1291 ? 1 1291 ? 2 1292 ? 1 1292 ? 2 1291 ? 1 224 ? 2 225 ? 1 225 ? 2 224 ? 1 933 ? 2 934 ? 1 934 ? 2 933 ? 803 933 ? 804 934 ? 803 934 ? 804 933 ? 789 933 ? 790 934 ? 789 934 ? 790 933 ? 78...
result:
wrong output format Unexpected end of file - int32 expected