QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#111262 | #6303. Inversion | xaphoenix# | WA | 103ms | 17524kb | C++14 | 1.9kb | 2023-06-06 15:46:45 | 2023-06-06 15:46:46 |
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], f[N][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;
res ^= f[l][r - 1];
cout << "? " << l + 1 << " " << r << endl;
fflush(stdout);
cin >> x, res ^= x;
if (l + 2 == r) return res;
res ^= f[l + 1][r - 1];
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;
int tmp = 0;
pern(j, 1, i - 1) {
tmp ^= (a[i] < a[j]);
f[j][i] = f[j][i - 1] ^ tmp;
}
}
cout << "!";
repn(i, 1, n) cout << " " << a[i];
cout << endl;
fflush(stdout);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3584kb
input:
3 0 0 1
output:
? 1 2 ? 1 3 ? 2 3 ! 2 3 1
result:
ok OK, guesses=3
Test #2:
score: -100
Wrong Answer
time: 103ms
memory: 17524kb
input:
1993 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 1 0 1 1 1
output:
? 1 2 ? 1 3 ? 2 3 ? 2 3 ? 2 4 ? 3 4 ? 3 4 ? 2 5 ? 3 5 ? 1 5 ? 2 5 ? 3 6 ? 4 6 ? 5 6 ? 2 6 ? 3 6 ? 3 7 ? 4 7 ? 5 7 ? 6 7 ? 4 8 ? 5 8 ? 6 8 ? 7 8 ? 3 8 ? 4 8 ? 4 9 ? 5 9 ? 6 9 ? 7 9 ? 7 9 ? 8 9 ? 0 10
result:
wrong output format Unexpected end of file - int32 expected