QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#439843#1813. Joy with PermutationsKalenistWA 1ms3668kbC++201.2kb2024-06-12 19:34:572024-06-12 19:34:59

Judging History

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

  • [2024-06-12 19:34:59]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3668kb
  • [2024-06-12 19:34:57]
  • 提交

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);
    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[2]],v2=val[id[3]];
    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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
4
3
3
4
3
3
5
4

output:

? 1 2 3 4
? 1 1 3 4
? 1 1 2 4
? 1 1 2 3
? 1 2 1 5
? 1 5 3 1
? 2 5 3
? 2 1 4
! 5 3 3 4 1 

result:

wrong answer Guess is wrong