QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#33240 | #1813. Joy with Permutations | Y25t | WA | 1ms | 3772kb | C++20 | 1.0kb | 2022-05-30 18:34:58 | 2024-04-09 18:56:52 |
Judging History
answer
#include<bits/stdc++.h>
inline int query1(int x,int y){
printf("? 2 %d %d\n",x+1,y+1),fflush(stdout);
int res;
scanf("%d",&res);
return res;
}
inline int query2(int x,int y,int z){
printf("? 1 %d %d %d\n",x+1,y+1,z+1),fflush(stdout);
int res;
scanf("%d",&res);
return res;
}
int main(){
int n;
scanf("%d",&n);
std::vector<int> a({query2(1,2,3),query2(0,2,3),query2(0,1,3),query2(0,1,2)}),b({0,1,2,3});
std::sort(b.begin(),b.end(),[&](int i,int j){
return a[i]>a[j];
});
int x=b[0],y=b[1],l=a[b[2]],z=b[2],w=b[3],r=a[b[0]];
std::vector<int> res(n);
for(int i=4;i<n;i++){
int t=query2(x,z,i);
if(t>l&&t<r)
res[i]=t;
else if(t==l)
res[x]=l,x=i,l=query2(x,z,y);
else if(t<l)
res[y]=l,y=i,l=t;
else if(t==r)
res[z]=r,z=i,r=query2(x,z,w);
else
res[w]=r,w=i,r=t;
}
if(query1(x,y))
std::swap(x,y);
res[x]=2,res[y]=1;
if(query1(z,w))
std::swap(z,w);
res[z]=n,res[w]=n-1;
printf("! ");
for(auto i:res)
printf("%d ",i);
puts("");
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3772kb
input:
5 4 3 3 4 3 2 4 3
output:
? 1 2 3 4 ? 1 1 3 4 ? 1 1 2 4 ? 1 1 2 3 ? 1 1 2 5 ? 1 5 2 4 ? 2 5 4 ? 2 2 3 ! 3 4 5 2 1
result:
wrong answer Guess is wrong