QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#742374#9432. PermutationEric998WA 290ms3848kbC++141.3kb2024-11-13 16:28:282024-11-13 16:28:29

Judging History

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

  • [2024-11-13 16:28:29]
  • 评测
  • 测评结果:WA
  • 用时:290ms
  • 内存:3848kb
  • [2024-11-13 16:28:28]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define N 1005
int fin[N], n;

void solve(int l, int r, vector<int> &v) {
	if (v.size() == 1) {
		fin[l] = v[0];
		return;
	}
	shuffle(v.begin(), v.end(), mt19937());
	int md = (l + r) / 2;
	vector<int> lv, rv;
	set<int> st;
	for (int i = 0; i < v.size(); i++) {
		if (lv.size() == md - l + 1) {
			rv.push_back(v[i]);
			continue;
		}	else if (rv.size() == r - md) {
			lv.push_back(v[i]);
			continue;
		}	else if (!st.size()) {
			st.insert(v[i]);
			continue;
		}
		int tp = *st.begin();
		st.erase(tp);
		cout << "0 ";
		for (int j = 1; j <= md; j++)
			cout << tp << ' ';
		for (int j = md + 1; j <= n; j++)
			cout << v[i] << ' ';
		cout << endl;
		int qry;
		cin >> qry;
		if (qry == 2)
			lv.push_back(tp), rv.push_back(v[i]);
		else if (!qry)
			rv.push_back(tp), lv.push_back(v[i]);
		else
			st.insert(tp), st.insert(v[i]);
	}
	for (int it : st) {
		if (lv.size() == md - l + 1)
			rv.push_back(it);
		else
			lv.push_back(it);
	}
	solve(l, md, lv), solve(md + 1, r, rv);
}

int main() {
	cin >> n;
	vector<int> v;
	for (int i = 1; i <= n; i++)
		v.push_back(i);
	solve(1, n, v);
	cout << "1 ";
	for (int i = 1; i <= n; i++)
		cout << fin[i] << ' ';
	cout << endl;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3780kb

input:

5
1
2
2
2
2
0

output:

0 4 4 4 3 3 
0 3 3 3 5 5 
0 4 4 4 1 1 
0 3 3 2 2 2 
0 3 4 4 4 4 
0 5 5 5 5 1 
1 3 4 2 1 5 

result:

ok Accepted

Test #2:

score: -100
Wrong Answer
time: 290ms
memory: 3848kb

input:

1000
0
0
2
0
1
0
0
0
0
1
0
0
0
1
2
2
0
1
0
1
1
0
1
1
1
0
1
0
0
1
0
1
0
1
1
0
0
0
1
0
1
0
0
1
1
0
0
1
0
0
0
2
1
0
0
1
1
1
1
0
1
1
1
1
0
1
1
1
1
0
0
0
1
1
1
1
1
1
0
1
1
1
1
1
0
0
0
1
1
0
1
0
1
1
1
0
1
0
0
1
0
1
1
0
0
0
0
1
0
1
1
1
0
1
1
1
0
0
0
1
1
1
0
1
0
0
1
1
0
0
1
0
1
1
1
0
1
0
0
0
1
1
1
0
1
1
0
0...

output:

0 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 20...

result:

wrong answer More than 6666 quries