QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#300448 | #6303. Inversion | mendicillin2# | AC ✓ | 136ms | 31572kb | C++17 | 2.8kb | 2024-01-08 11:49:46 | 2024-01-08 11:49:46 |
Judging History
answer
#include <bits/stdc++.h>
#include <ostream>
using namespace std;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
constexpr bool TESTING = false;
using ll = int64_t;
const int N = 2010;
int n;
int a_actual[N];
int id[N], a[N], ok[N][N], f[N][N];
int num_queries = 0;
inline bool qry(int l, int r) {
assert(1 <= l && l <= r && r <= n);
if (ok[l][r]) return f[l][r];
cout << "? " << l << ' ' << r << endl;
bool cur;
if constexpr (!TESTING) {
cin >> cur;
} else {
cur = false;
for (int i = l; i <= r; i++) {
for (int j = i+1; j <= r; j++) {
cur ^= (a_actual[i] > a_actual[j]);
}
}
}
num_queries++;
f[l][r] = cur;
ok[l][r] = 1;
return cur;
}
int ni[N], t[N];
inline int lowbit(int x) { return x & (-x); }
inline void add(int x, int r) {
for (int i = x; i <= r; i += lowbit(i)) t[i] ^= 1;
}
inline bool sum(int x) {
bool now = 0;
for (int i = x; i; i -= lowbit(i)) now ^= t[i];
return now;
}
inline void build(int r) {
for (int i = 1; i <= r; i ++) t[i] = 0;
for (int i = r; i >= 1; i --) { ni[i] = sum(a[i]); add(a[i], r); }
for (int i = r - 1; i >= 1; i --) ni[i] ^= ni[i + 1];
}
inline bool check(int p, int x) {
if (id[p] + 1 == x) return !qry(id[p], x);
int a1 = qry(id[p], x), a2 = qry(id[p] + 1, x), a3 = ni[id[p]], a4 = ni[id[p] + 1];
//cout << p << ' ' << id[p] << ' ' << x << endl;
//cout << a1 << a2 << a3 << a4 << endl;
return !(a1 ^ a2 ^ a3 ^ a4);
}
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
int rand_int(int lo, int hi) {
return uniform_int_distribution<int>(lo, hi)(mt);
}
int main() {
ios_base::sync_with_stdio(false), cin.tie(nullptr);
cout << fixed << setprecision(20);
if constexpr (!TESTING) {
cin >> n;
} else {
n = rand_int(3, 10);
iota(a_actual + 1, a_actual + n + 1, 1);
shuffle(a_actual + 1, a_actual + n + 1, mt);
}
id[1] = 1;
a[1] = 1;
for (int i = 2; i <= n; i ++) {
int l = 1, r = i - 1, ans = 0;
while (l <= r) {
int mid = (l + r) >> 1;
if (check(mid, i)) { ans = mid; l = mid + 1; }
else r = mid - 1;
}
for (int j = i - 1; j > ans; j --) {
a[id[j]] = j + 1;
id[j + 1] = id[j];
}
id[ans + 1] = i;
a[i] = ans + 1;
build(i);
//for (int j = 1; j <= n; j ++) cout << ni[j] << ' ';
//cout << endl;
}
cout << "! ";
for (int i = 1; i < n; i ++) cout << a[i] << ' ';
cout << a[n] << endl;
assert(num_queries <= 40000);
if constexpr (TESTING) {
bool works = true;
for (int i = 1; i <= n; i++) {
works &= (a[i] == a_actual[i]);
}
if (!works) {
for (int i = 1; i <= n; i++) {
cerr << a[i] << " \n"[i==n];
}
for (int i = 1; i <= n; i++) {
cerr << a_actual[i] << " \n"[i==n];
}
assert(false);
}
}
return 0;
}
/*
1 2 6 4 3 5
2 3 5 4 1 6
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3728kb
input:
3 0 0 1
output:
? 1 2 ? 1 3 ? 2 3 ! 2 3 1
result:
ok OK, guesses=3
Test #2:
score: 0
Accepted
time: 136ms
memory: 30912kb
input:
1993 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 1 0 1 1 1 1 1 0 0 0 1 0 1 0 1 0 0 0 0 1 1 0 0 1 0 0 1 1 1 1 1 0 1 1 1 1 1 1 0 0 0 0 0 0 1 0 1 1 1 0 0 1 0 1 1 0 1 1 0 1 1 0 0 1 0 0 0 1 1 0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
time: 1ms
memory: 3696kb
input:
1
output:
! 1
result:
ok OK, guesses=0
Test #20:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
2 0
output:
? 1 2 ! 1 2
result:
ok OK, guesses=1
Test #21:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
2 1
output:
? 1 2 ! 2 1
result:
ok OK, guesses=1
Test #22:
score: 0
Accepted
time: 62ms
memory: 29836kb
input:
1997 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
? 1 2 ? 2 3 ? 1 3 ? 1 4 ? 2 4 ? 3 4 ? 4 5 ? 1 5 ? 2 5 ? 3 5 ? 1 6 ? 2 6 ? 3 6 ? 4 6 ? 1 7 ? 2 7 ? 3 7 ? 4 7 ? 5 7 ? 6 7 ? 6 8 ? 7 8 ? 5 8 ? 3 8 ? 4 8 ? 6 9 ? 7 9 ? 8 9 ? 5 9 ? 3 10 ? 4 10 ? 5 10 ? 6 10 ? 7 10 ? 8 10 ? 3 11 ? 4 11 ? 10 11 ? 7 11 ? 8 11 ? 9 11 ? 8 12 ? 9 12 ? 7 12 ? 10 12 ? 8 13 ? 9 1...
result:
ok OK, guesses=35294
Test #23:
score: 0
Accepted
time: 71ms
memory: 29800kb
input:
1998 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1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