QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#439856#1813. Joy with PermutationsKalenistWA 1ms3856kbC++201.2kb2024-06-12 19:44:212024-06-12 19:44:21

Judging History

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

  • [2024-06-12 19:44:21]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3856kb
  • [2024-06-12 19:44:21]
  • 提交

answer

#include<bits/stdc++.h>
#define N 60010
#define For(i,a,b) for(register int i=a;i<=b;i++)
using namespace std;
int n,id[5],val[5],ans[N];
inline bool rule(int a,int b){return val[a]>val[b];}
inline int ask1(int a,int b,int c)
{
    cout<<"? 1 "<<a<<" "<<b<<" "<<c<<endl,cout.flush();
    int x;scanf("%d",&x);
    return x;
}

inline int ask2(int a,int b)
{
    cout<<"? 2 "<<a<<" "<<b<<endl,cout.flush();
    int x;scanf("%d",&x);
    printf("got: %d\n",x);
    return x;
}

int main()
{
    scanf("%d",&n);
    For(i,1,4) id[i]=i;
    val[1]=ask1(2,3,4),val[2]=ask1(1,3,4);
    val[3]=ask1(1,2,4),val[4]=ask1(1,2,3);
    sort(id+1,id+5,rule);
    int a=id[1],b=id[2],c=id[3],d=id[4];
    int v1=val[id[3]],v2=val[id[2]];
    For(i,5,n)
    {
        int nw=ask1(a,c,i);
        if(nw > v1 && nw < v2) ans[i]=nw;
        else if(nw == v1) ans[a]=v1,a=i,v1=ask1(a,b,c);
        else if(nw == v2) ans[c]=v2,c=i,v2=ask1(b,c,d);
        else if(nw < v1) ans[b]=v1,b=i,v1=ask1(a,b,c);
        else ans[d]=v2,d=i,v2=ask1(b,c,d);
    }if(ask2(a,b) != a) swap(a,b);
    if(ask2(c,d) != c) swap(c,d);
    ans[a]=1,ans[b]=v1,ans[c]=v2,ans[d]=n;
    cout<<"! ";
    For(i,1,n) cout<<ans[i]<<" ";
    cout.flush();
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3856kb

input:

5
4
3
3
4
3
2
4

output:

? 1 2 3 4
? 1 1 3 4
? 1 1 2 4
? 1 1 2 3
? 1 1 2 5
? 1 5 4 2
? 2 5 4
got: 4
? 2 2 3

result:

wrong answer invalid query