QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#33210#1813. Joy with PermutationsWu_RenWA 1ms3764kbC++171.1kb2022-05-30 08:25:092024-04-09 18:56:45

Judging History

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

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

answer

#include <bits/stdc++.h>
using namespace std;
int n,a[5],p[60010];
vector<int>B,S;
int qry(int x,int y,int z){
	printf("? 1 %d %d %d\n",x,y,z),fflush(stdout);
	scanf("%d",&x);
	return x;
}
int qry2(int x,int y){
	printf("? 2 %d %d\n",x,y),fflush(stdout);
	scanf("%d",&x);
	return x;
}
int main(){
	scanf("%d",&n);
	a[1]=qry(2,3,4),a[2]=qry(1,3,4),a[3]=qry(1,2,4),a[4]=a[1]^a[2]^a[3];
	int smn=min({a[1],a[2],a[3],a[4]}),smx=max({a[1],a[2],a[3],a[4]});
	for(int i=1;i<=4;i++) ((a[i]^smx)?B:S).push_back(i);
	for(int i=5;i<=n;i++){
		int x=qry(S[1],i,B[1]);
		if(smn>x){
			p[S[0]]=smn,smn=x;
			S[0]=i;
		}
		else if(smn==x){
			p[S[1]]=x,S[1]=i;
			smn=qry(S[0],i,B[0]);
		}
		else if(x<smx){
			p[i]=x;
		}
		else if(x==smx){
			p[B[1]]=x,B[1]=i;
			smx=qry(S[0],i,B[0]);
		}
		else{
			p[B[0]]=x,smx=x;
			B[0]=i;
		}
	}
	if(qry2(B[0],B[1])^B[0]) swap(B[0],B[1]);
	if(qry2(S[0],S[1])^S[0]) swap(S[0],S[1]);
	p[B[0]]=n-1,p[B[1]]=n,p[S[0]]=1,p[S[1]]=2;
	printf("? ");
	for(int i=1;i<=n;i++) printf("%d ",p[i]);puts(""),fflush(stdout);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3764kb

input:

5
4
3
3
2
3
4

output:

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

result:

wrong answer Integer 3 violates the range [1, 2]