QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#742342#9432. PermutationEric998WA 303ms3624kbC++141.3kb2024-11-13 16:25:502024-11-13 16:25:58

Judging History

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

  • [2024-11-13 16:25:58]
  • 评测
  • 测评结果:WA
  • 用时:303ms
  • 内存:3624kb
  • [2024-11-13 16:25:50]
  • 提交

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;
	}
	random_shuffle(v.begin(), v.end());
	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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
0
1
2
1
2
0
2

output:

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

result:

ok Accepted

Test #2:

score: -100
Wrong Answer
time: 303ms
memory: 3624kb

input:

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

output:

0 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 11...

result:

wrong answer More than 6666 quries