QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#33242 | #1813. Joy with Permutations | Y25t | AC ✓ | 1ms | 3852kb | C++20 | 1.0kb | 2022-05-30 18:36:36 | 2024-04-09 18:48:48 |
Judging History
你现在查看的是测评时间为 2024-04-09 18:48:48 的历史记录
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2022-05-30 18:36:36]
- 提交
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==x+1;
}
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("");
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3852kb
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 5 4 1 2
result:
wrong answer ok OK (6 2)