QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#396443#1813. Joy with PermutationsNetwork_ErrorTL 0ms0kbC++141.5kb2024-04-22 19:44:192024-04-22 19:44:20

Judging History

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

  • [2024-04-22 19:44:20]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-04-22 19:44:19]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define piii tuple<int,int,int>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define deb(var) cerr<<#var<<'='<<(var)<<"; "
#define int long long
int n,ans[100010];
int ask(int x,int y,int z){
	printf("? 1 %d %d %d",x,y,z);
	cout<<endl;
	int o;cin>>o;return o;
}
bool lt(int x,int y){
	printf("? 2 %d %d",x,y);
	cout<<endl;
	int o;cin>>o;return o==x;
}
void work(){
	cin>>n;
	int t1,t2,t3,t4;
	tie(t1,t2,t3,t4)=mt(ask(1,2,3),ask(1,2,4),ask(1,3,4),ask(2,3,4));
	int a,b,c,d,l=min({t1,t2,t3,t4}),r=max({t1,t2,t3,t4});
		 if(t1==t2&&t2==l)a=1,b=2,c=3,d=4;
	else if(t1==t3&&t3==l)a=1,b=3,c=2,d=4;
	else if(t1==t4&&t4==l)a=2,b=3,c=1,d=4;
	else if(t2==t3&&t3==l)a=1,b=4,c=2,d=3;
	else if(t2==t4&&t4==l)a=2,b=4,c=1,d=3;
	else if(t3==t4&&t4==l)a=3,b=4,c=1,d=2;
	//----------------------------------------------------------------
	for(int i=5;i<=n;i++){
		int O=ask(a,c,i);
		if(l<O&&O<r)ans[i]=O;
		else if(O<l){
			ans[b]=l;b=i,l=O;
		}else if(O>r){
			ans[d]=r;d=i,r=O;
		}else if(O==l){
			ans[a]=O;a=i,l=ask(a,b,c);
		}else if(O==r){
			ans[c]=O;c=i;r=ask(c,d,a);
		}
	}
	#define p ans
	if(lt(a,b))p[a]=1,p[b]=2;else p[a]=2,p[b]=1;
	if(lt(c,d))p[c]=n-1,p[d]=n;else p[c]=n,p[d]=n-1;
	cout<<"! ";for(int i=1;i<=n;i++)cout<<ans[i]<<' ';cout<<endl;
}
signed main(){
	ios::sync_with_stdio(0),
	cin.tie(0),cout.tie(0);
	int T=1;while(T--)work();return 0;
}

詳細信息

Test #1:

score: 0
Time Limit Exceeded

input:

5

output:



result: