QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#111257 | #6303. Inversion | xaphoenix# | WA | 117ms | 3572kb | C++14 | 1.9kb | 2023-06-06 15:32:44 | 2023-06-06 15:32:45 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define LC k<<1
#define RC k<<1|1
#define IO cin.sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define rep(i,a,n) for (int i = a; i < n; i++)
#define repn(i,a,n) for (int i = a; i <= n; i++)
#define per(i,a,n) for (int i = (n) - 1; i >= a; i--)
#define pern(i,a,n) for (int i = n; i >= a; i--)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;
typedef pair<double, double> PDD;
typedef pair<ull, ull> PUU;
typedef pair<LL, LL> PLL;
const int N = 2100;
const int M = 1100000;
const int mod = 1e9+7;
const int inf = (int)1e9;
const LL INF = 1e18;
const double eps = 1e-9;
mt19937_64 Rand((unsigned long long)new char);
#define rand Rand
int n, pos[N], a[N];
int get(int l, int r) {
int res = 0, x;
cout << "? " << l << " " << r << endl;
fflush(stdout);
cin >> x, res ^= x;
if (l + 1 == r) return res;
cout << "? " << l << " " << r - 1 << endl;
fflush(stdout);
cin >> x, res ^= x;
cout << "? " << l + 1 << " " << r << endl;
fflush(stdout);
cin >> x, res ^= x;
if (l + 2 == r) return res;
cout << "? " << l + 1 << " " << r - 1 << endl;
fflush(stdout);
cin >> x, res ^= x;
return res;
}
int main() {
IO;
cin >> n;
pos[1] = 1;
a[1] = 1;
repn(i, 2, n) {
int l = 1, r = i - 1, ans = 0;
while (l <= r) {
int mid = (l + r) / 2;
if (!get(pos[mid], i)) l = mid + 1, ans = mid;
else r = mid - 1;
}
repn(j, 1, i - 1) if (a[j] > ans) a[j]++;
a[i] = ans + 1;
repn(j, 1, i) pos[a[i]] = i;
}
cout << "!";
repn(i, 1, n) cout << " " << a[i];
cout << endl;
fflush(stdout);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3572kb
input:
3 0 0 0 1
output:
? 1 2 ? 1 3 ? 1 2 ? 2 3 ! 2 3 1
result:
ok OK, guesses=4
Test #2:
score: -100
Wrong Answer
time: 117ms
memory: 3336kb
input:
1993 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 1 0 1 0 0 1 1 0 0 0 0 1 0 0 1 0 0 1 1 0 1
output:
? 1 2 ? 1 3 ? 1 2 ? 2 3 ? 2 3 ? 2 4 ? 2 3 ? 3 4 ? 3 4 ? 2 5 ? 2 4 ? 3 5 ? 3 4 ? 1 5 ? 1 4 ? 2 5 ? 2 4 ? 3 6 ? 3 5 ? 4 6 ? 4 5 ? 5 6 ? 2 6 ? 2 5 ? 3 6 ? 3 5 ? 3 7 ? 3 6 ? 4 7 ? 4 6 ? 5 7 ? 5 6 ? 6 7 ? 4 8 ? 4 7 ? 5 8 ? 5 7 ? 6 8 ? 6 7 ? 7 8 ? 3 8 ? 3 7 ? 4 8 ? 4 7 ? 4 9 ? 4 8 ? 5 9 ? 5 8 ? 6 9 ? 6 8 ...
result:
wrong output format Unexpected end of file - int32 expected