QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#371993#6303. Inversionucup-team956WA 59ms3632kbC++171.8kb2024-03-30 19:06:382024-03-30 19:06:38

Judging History

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

  • [2024-03-30 19:06:38]
  • 评测
  • 测评结果:WA
  • 用时:59ms
  • 内存:3632kb
  • [2024-03-30 19:06:38]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define time chrono::system_clock::now().time_since_epoch().count()
mt19937_64 rnd(time);
#define maxn 2005
#define int long long

int read() {int x;cin>>x;return x;}

int f[maxn][maxn];

int ask(int l, int r) {
	if(l >= r) return 0;
	if(f[l][r] != -1) return f[l][r];
	cout << "? " << l << " " << r << endl;
	int x;
	cin >> x;
	f[l][r] = x;
	return f[l][r];
}

signed main() {
	// #ifdef ONLINE_JUDGE
		// ios::sync_with_stdio(false);
		// cin.tie(0);cout.tie(0);
	// #else
		// freopen("a.in", "r", stdin);
	// #endif

	int n = read();
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++)
			f[i][j] = -1;
	}
	for(int i = 1; i <= 40000; i++) {
		cout << "? " << 1 << " " << 1 << endl;
		int x = read();
	}
	vector<int> a(n + 1), pos(n + 1);
	a[1] = 1;
	for(int i = 1; i <= n; i++) f[i][i] = 0;
	for(int i = 2; i <= n; i++) {
		int l = 1, r = i - 1;
		auto check = [&](int mid) -> int {
			int val = ask(pos[mid], i) ^ ask(pos[mid] + 1, i) ^ ask(pos[mid], i - 1) ^ ask(pos[mid] + 1, i - 1);
			// cout << "---- " << pos[mid] << " ";
			// cout << ask(pos[mid], i) << " " <<  ask(pos[mid] + 1, i) << " " << ask(pos[mid], i - 1) << " " << ask(pos[mid] + 1, i - 1) << endl;
			if(val == 1) return 1; // a[mid] > a[i]
			else return 0; // a[mid] < a[i]
		};
		while(l <= r) {
			int mid = (l + r) >> 1;
			if(check(mid)) r = mid - 1;
			else l = mid + 1;
		}
		a[i] = l;
		// cout << a[i] << "\n";
		for(int j = 1; j < i; j++) if(a[j] >= a[i]) a[j] += 1;
		for(int j = 1; j <= i; j++) pos[a[j]] = j;
		int tot = 0;
		for(int j = i - 1; j >= 1; j--) {
			tot += (a[i] < a[j]);
			f[j][i] = f[j][i - 1] + tot;
		}
	}
	cout << "! ";
	for(int i = 1; i <= n; i++) cout << a[i] << " ";
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 59ms
memory: 3632kb

input:

3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

output:

? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
...

result:

wrong output format Unexpected end of file - int32 expected