QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#744359#9432. PermutationjiamengtongWA 1ms4096kbC++141.1kb2024-11-13 21:39:272024-11-13 21:39:27

Judging History

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

  • [2024-11-13 21:39:27]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4096kb
  • [2024-11-13 21:39:27]
  • 提交

answer

#include<bits/stdc++.h>
#define M 1005
using namespace std;
int n, ans[M], a[M];
int ask(int l, int r, int x, int y)
{
	int mid = (l + r) >> 1;
	printf("0 ");
	for(int i = 1; i <= mid; i++) printf("%d ", x);
	for(int i = mid + 1; i <= n; i++) printf("%d ", y);
	puts("");
	fflush(stdout);
	int res;
	scanf("%d", &res);
	return res;
}
void solve(int l, int r, vector<int> v)
{
	if(l == r)
	{
		ans[l] = v[0];
		return;
	}
	random_shuffle(v.begin(), v.end());
	vector<int> L[2];
	int fl = 0, lst = 0;
	L[0].push_back(v[0]);
	for(int i = 1; i < v.size(); i++)
	{
		int w = ask(l, r, v[i - 1], v[i]);
		if(w != 1)
		{
			L[lst ^ 1].push_back(v[i]), lst ^= 1;
			if(!fl)
			{
				if(w == 0) fl = lst;
				else fl = lst ^ 1;
			}
		}
		else
		{
			L[lst].push_back(v[i]);
		}
	}
	int mid = (l + r) >> 1;
	solve(l, mid, L[fl]);
	solve(mid + 1, r, L[fl ^ 1]);
}
int main()
{
	scanf("%d", &n);
	vector<int> v;
	for(int i = 1; i <= n; i++) v.push_back(i);
	if(n<500)solve(1, n, v);
	printf("1 ");
	for(int i = 1; i <= n; i++) printf("%d ", ans[i]);
	puts("");
	fflush(stdout);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
0
1
1
2
1
2
2
2

output:

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

result:

ok Accepted

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 4096kb

input:

1000

output:

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

result:

wrong answer Integer element [index=1] equals to 0, violates the range [1, 1000]