QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#290160#6303. Inversionzzuqy#WA 56ms19464kbC++14928b2023-12-24 14:54:212023-12-24 14:54:22

Judging History

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

  • [2023-12-24 14:54:22]
  • 评测
  • 测评结果:WA
  • 用时:56ms
  • 内存:19464kb
  • [2023-12-24 14:54:21]
  • 提交

answer

#include <bits/stdc++.h>
#define N 2009
using namespace std;
int ans2[N][N];

bool query(int l, int r) {
	if (l == r)
		return 0;
	if (ans2[l][r] != -1)
		return ans2[l][r];
	cout << "? " << l << " " << r << endl;
	cin >> ans2[l][r];
	return ans2[l][r];
}
int n;
int par[N], a[N], ra[N];

int main() {
	fill(ans2[0], ans2[0] + N * N, -1);
	cin >> n;
	a[1] = 1;
	ra[1] = 1;
	for (int i = 2; i <= n; i++) {
		int l = 1, r = i;
		while (l < r) {

			int mid = (l + r ) >> 1;
			//cout << l << " " << r << " " << mid << endl;
			int tmp1 = query(ra[mid], i)^par[ra[mid]];
			int tmp2 = query(ra[mid] + 1, i)^par[ra[mid] + 1];
			if (tmp1 == tmp2)
				l = mid + 1;
			else
				r = mid;
		}
		for (int j = 1; j < i; j++)
			if (a[j] >= l)
				a[j]++, ra[a[j]] = j;
		a[i] = l;
		ra[l] = i;
	}
	cout << "! ";
	for (int i = 1; i <= n; i++)
		cout << a[i] << " ";
	cout << endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 19464kb

input:

3
0
1
0

output:

? 1 2
? 2 3
? 1 3
! 2 3 1 

result:

ok OK, guesses=3

Test #2:

score: -100
Wrong Answer
time: 56ms
memory: 19372kb

input:

1993
0
0
0
0
0
1
1
0
0
0
0
0
0
1
0
1
0
1
1
0
0
1
0
1
1
0
1
0
1
1
1
0
1
1
0
1
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
0
0
0
1
1
0
0
0
0
0
1
1
0
0
0
0
1
0
1
1
1
1
1
1
0
1
1
0
0
1
0
1
0
0
0
1
1
0
0
1
0
1
0
0
0
1
1
1
0
0
1
0
1
0
1
1
0
0
0
0
0
0
0
1
1
0
0
1
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
1
1
0
0...

output:

? 1 2
? 2 3
? 2 4
? 3 4
? 3 5
? 4 5
? 2 5
? 1 5
? 2 6
? 3 6
? 4 6
? 5 6
? 3 7
? 4 7
? 1 7
? 2 7
? 5 7
? 6 7
? 2 8
? 3 8
? 5 8
? 6 8
? 7 8
? 2 9
? 3 9
? 4 9
? 5 9
? 2 10
? 3 10
? 5 10
? 6 10
? 1 10
? 2 11
? 3 11
? 4 11
? 5 11
? 9 11
? 10 11
? 2 12
? 3 12
? 4 12
? 6 12
? 7 12
? 9 13
? 10 13
? 4 13
? 5...

result:

wrong answer Wa.