QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#33241#1813. Joy with PermutationsY25tWA 0ms3772kbC++201.0kb2022-05-30 18:36:142024-04-09 18:56:54

Judging History

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

  • [2024-04-09 18:56:54]
  • 管理员手动重测本题所有提交记录
  • 测评结果:WA
  • 用时:0ms
  • 内存:3772kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-30 18:36:16]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3756kb
  • [2022-05-30 18:36:14]
  • 提交

answer

#include<bits/stdc++.h>

inline int query1(int x,int y){
	printf("? 2 %d %d\n",x+1,y+1),fflush(stdout);
	int res;
	scanf("%d",&res);
	return res==x;
}
inline int query2(int x,int y,int z){
	printf("? 1 %d %d %d\n",x+1,y+1,z+1),fflush(stdout);
	int res;
	scanf("%d",&res);
	return res;
}

int main(){
	int n;
	scanf("%d",&n);
	std::vector<int> a({query2(1,2,3),query2(0,2,3),query2(0,1,3),query2(0,1,2)}),b({0,1,2,3});
	std::sort(b.begin(),b.end(),[&](int i,int j){
		return a[i]>a[j];
	});
	int x=b[0],y=b[1],l=a[b[2]],z=b[2],w=b[3],r=a[b[0]];
	std::vector<int> res(n);
	for(int i=4;i<n;i++){
		int t=query2(x,z,i);
		if(t>l&&t<r)
			res[i]=t;
		else if(t==l)
			res[x]=l,x=i,l=query2(x,z,y);
		else if(t<l)
			res[y]=l,y=i,l=t;
		else if(t==r)
			res[z]=r,z=i,r=query2(x,z,w);
		else
			res[w]=r,w=i,r=t;
	}
	if(query1(x,y))
		std::swap(x,y);
	res[x]=2,res[y]=1;
	if(query1(z,w))
		std::swap(z,w);
	res[z]=n,res[w]=n-1;
	printf("! ");
	for(auto i:res)
		printf("%d ",i);
	puts("");
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3772kb

input:

5
4
3
3
4
3
2
4
3

output:

? 1 2 3 4
? 1 1 3 4
? 1 1 2 4
? 1 1 2 3
? 1 1 2 5
? 1 5 2 4
? 2 5 4
? 2 2 3
! 3 5 4 2 1 

result:

wrong answer Guess is wrong