QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#33240#1813. Joy with PermutationsY25tWA 1ms3772kbC++201.0kb2022-05-30 18:34:582024-04-09 18:56:52

Judging History

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

  • [2024-04-09 18:56:52]
  • 管理员手动重测本题所有提交记录
  • 测评结果:WA
  • 用时:1ms
  • 内存: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:35:01]
  • 评测
  • 测评结果:0
  • 用时:3ms
  • 内存:3792kb
  • [2022-05-30 18:34:58]
  • 提交

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;
}
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("");
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
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 4 5 2 1 

result:

wrong answer Guess is wrong