QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#32402#1813. Joy with PermutationsAppleblue17TL 0ms0kbC++1.5kb2022-05-19 21:02:212022-05-19 21:02:23

Judging History

你现在查看的是测评时间为 2022-05-19 21:02:23 的历史记录

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

answer

#include<bits/stdc++.h>
using namespace std;
const int N=66000;
int n;
int p[N];

int query(int x,int y,int z){
	cout<<"? 1 "<<x<<" "<<y<<" "<<z<<endl;
	int tot;
//	tot=p[x]+p[y]+p[z]-min({p[x],p[y],p[z]})-max({p[x],p[y],p[z]});
	cin>>tot;
	return tot;
}
int A,B,C,D,mn,mx;
pair <int,int> a[4];
int ans[N];

int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>p[i];
	a[0]=make_pair(query(1,2,3),(1|2|4)),a[1]=make_pair(query(1,3,4),(1|4|8)),
	a[2]=make_pair(query(1,2,4),(1|2|8)),a[3]=make_pair(query(2,3,4),(2|4|8));
	sort(a,a+4);
	int x=a[0].second & a[1].second,y=a[2].second & a[3].second;
	if(x==3) A=1,B=2;
	else if(x==5) A=1,B=3;
	else if(x==9) A=1,B=4;
	else if(x==6) A=2,B=3;
	else if(x==10) A=2,B=4;
	else if(x==12) A=3,B=4;
	
	if(y==3) C=1,D=2;
	else if(y==5) C=1,D=3;
	else if(y==9) C=1,D=4;
	else if(y==6) C=2,D=3;
	else if(y==10) C=2,D=4;
	else if(y==12) C=3,D=4;
	
	mn=a[0].first,mx=a[2].first;
	
	for(int i=5;i<=n;i++){
		int x=query(A,C,i);
		if(x==mn){
			ans[A]=mn;
			A=i;
			mn=query(A,B,C);
		}
		else if(x==mx){
			ans[C]=mx;
			C=i;
			mx=query(B,C,D);
		}
		else if(mn<x && x<mx){
			ans[i]=x;
		}
		else if(x<mn){
			ans[B]=mn;
			mn=x;
			B=i;
		}
		else if(x>mx){
			ans[D]=mx;
			mx=x;
			D=i;
		}
	}
	
	cout<<"? 2 "<<A<<" "<<B<<endl;
	cin>>x;
	if(x==A) ans[A]=1,ans[B]=2;
	else ans[A]=2,ans[B]=1;
	
	cout<<"? 2 "<<C<<" "<<D<<endl;
	cin>>x;
	if(x==C) ans[C]=n-1,ans[D]=n;
	else ans[C]=n,ans[D]=n-1;
	
	cout<<"! ";
	for(int i=1;i<=n;i++) cout<<ans[i]<<" ";
	cout<<endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

5

output:


result: