QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#391788#6303. InversionCore_65536WA 1ms3600kbC++141.1kb2024-04-16 19:43:302024-04-16 19:43:30

Judging History

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

  • [2024-04-16 19:43:30]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3600kb
  • [2024-04-16 19:43:30]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define endl "\n"

using namespace std;

bool cmp(int r,int l){
    if(r-l==1){
        cout<<"? "<<l<<" "<<r<<endl;    fflush(stdout);
        int ans;    cin>>ans;
        return (!ans);
    }
    int a=0,b=0,c=0,d=0;
    if(l!=r){
        cout<<"? "<<l<<" "<<r<<endl;    fflush(stdout);
        cin>>a;
    }
    if(l+1!=r){
        cout<<"? "<<l+1<<" "<<r<<endl;  fflush(stdout);
        cin>>b;
    }
    if(l!=r-1){
        cout<<"? "<<l<<" "<<r-1<<endl;    fflush(stdout);
        cin>>c;
    }
    if(l+1!=r-1){
        cout<<"? "<<l+1<<" "<<r-1<<endl;  fflush(stdout);
        cin>>d;
    }
    return (a-b-c+d)!=0;
}

void solve(){
    int n;  cin>>n;
    int ans[n+1];
    for(int i=1;i<=n;i++){
        ans[i]=i;
    }
    stable_sort(ans+1,ans+n+1,cmp);
    vector<int> v(n+1);
    for(int i=1;i<=n;i++){
        v[ans[i]]=i;
    }
    cout<<"! ";
    for(int i=1;i<=n;i++){
        cout<<v[i]<<" ";
    }
}

signed main(){
    ios::sync_with_stdio(0);
    int T=1;    //cin>>T;
    while(T--)  solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
0
0
1
0
1

output:

? 1 2
? 1 3
? 2 3
? 1 2
? 2 3
! 3 1 2 

result:

wrong answer Wa.