QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#361587 | #6303. Inversion | recollector# | WA | 44ms | 3668kb | C++20 | 1.3kb | 2024-03-23 11:45:44 | 2024-03-23 11:45:45 |
Judging History
answer
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <iostream>
#include <queue>
typedef long long LL;
using namespace std;
inline int read() {
int num = 0 ,f = 1; char c = getchar();
while (!isdigit(c)) f = c == '-' ? -1 : f ,c = getchar();
while (isdigit(c)) num = (num << 1) + (num << 3) + (c ^ 48) ,c = getchar();
return num * f;
}
const int N = 2005;
inline int ask(int l ,int r) {
if (l >= r) return 0;
cout << "? " << l << ' ' << r << endl;
int x = 0; cin >> x; return x;
}
inline bool cmp(int i ,int j) {
return ask(i ,j) ^ ask(i + 1 ,j) ^ ask(i ,j - 1) ^ ask(i + 1 ,j - 1);
}
int a[N] ,p[N] ,n;
signed main() {
cin >> n;
a[1] = 1;
for (int i = 2; i <= n; i++) {
int p = 0;
if (!cmp(a[1] ,i)) {
int l = 2 ,r = i;
while (l < r) {
int mid = (l + r) >> 1;
if (cmp(a[mid] ,i)) r = mid;
else l = mid + 1;
}
p = l - 1;
}
for (int j = i - 1; j >= p; j--) a[j + 1] = a[j];
a[p + 1] = i;
}
for (int i = 1; i <= n; i++) p[a[i]] = i;
cout << "! ";
for (int i = 1; i <= n; i++) cout << p[i] << ' ';
cout << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3668kb
input:
3 0 0 1 0
output:
? 1 2 ? 1 3 ? 2 3 ? 1 2 ! 2 3 1
result:
ok OK, guesses=4
Test #2:
score: -100
Wrong Answer
time: 44ms
memory: 3652kb
input:
1993 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 1 0 0 1 0 1 0 0 0 1 0 0 0 0 1 1 1 0 1 1 1 0 0 1 1 0 0 1 0 1 1 1 1 1 0 1 1 1 0 0 0 1 1 1 0 1 1 1 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 1 0 0 0 1 0 0 0 1 1 0...
output:
? 1 2 ? 1 3 ? 2 3 ? 1 2 ? 2 3 ? 1 4 ? 2 4 ? 1 3 ? 2 3 ? 3 4 ? 1 5 ? 2 5 ? 1 4 ? 2 4 ? 5 6 ? 3 6 ? 4 6 ? 3 5 ? 4 5 ? 2 6 ? 3 6 ? 2 5 ? 3 5 ? 1 6 ? 2 6 ? 1 5 ? 2 5 ? 5 7 ? 6 7 ? 5 6 ? 7 8 ? 2 8 ? 3 8 ? 2 7 ? 3 7 ? 4 8 ? 5 8 ? 4 7 ? 5 7 ? 3 8 ? 4 8 ? 3 7 ? 4 7 ? 7 9 ? 8 9 ? 7 8 ? 2 9 ? 3 9 ? 2 8 ? 3 8 ...
result:
wrong output format Unexpected end of file - int32 expected