QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#33210 | #1813. Joy with Permutations | Wu_Ren | WA | 1ms | 3764kb | C++17 | 1.1kb | 2022-05-30 08:25:09 | 2024-04-09 18:56:45 |
Judging History
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]