QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#32403 | #1811. How to Move the Beans | Appleblue17 | WA | 3ms | 3564kb | C++ | 1.5kb | 2022-05-19 21:05:21 | 2022-05-19 21:05:22 |
Judging History
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
Wrong Answer
time: 3ms
memory: 3564kb
input:
2 3 B.# #..
output:
? 1 1 2 3 ? 1 1 3 4 ? 1 1 2 4 ? 1 2 3 4 ? 2 1 4 ? 2 2 3 ! 2 2
result:
wrong answer 1st words differ - expected: 'Alice', found: '?'