QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#111259#6303. Inversionxaphoenix#WA 64ms17524kbC++141.9kb2023-06-06 15:36:042023-06-06 15:36:08

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-06 15:36:08]
  • 评测
  • 测评结果:WA
  • 用时:64ms
  • 内存:17524kb
  • [2023-06-06 15:36:04]
  • 提交

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 ^= (f[i] < f[j]);
			f[j][i] = f[j][i - 1] ^ tmp;
		}
	}
	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: 0ms
memory: 3436kb

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: 64ms
memory: 17524kb

input:

1993
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0

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
? 4 6
? 5 6
? 0 6

result:

wrong output format Unexpected end of file - int32 expected