QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#391789#6303. InversionCore_65536WA 15ms3856kbC++171.0kb2024-04-16 19:45:542024-04-16 19:45:55

Judging History

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

  • [2024-04-16 19:45:55]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:3856kb
  • [2024-04-16 19:45:54]
  • 提交

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);
    
    cout<<"! ";
    for(int i=1;i<=n;i++){
        cout<<ans[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: 100
Accepted
time: 1ms
memory: 3856kb

input:

3
0
0
1
0
1

output:

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

result:

ok OK, guesses=5

Test #2:

score: -100
Wrong Answer
time: 15ms
memory: 3836kb

input:

1993
0
0
0
1
0
1
0
0
1
0
0
0
0
1
0
1
0
0
1
1
0
1
0
0
1
0
0
0
0
1
0
0
0
1
0
1
0
0
0
1
1
1
1
1
1
0
0
0
1
0
1
0
0
1
0
0
0
1
1
0
0
0
1
0
1
0
1
0
0
1
1
1
1
1
0
0
1
0
1
0
0
0
1
1
0
1
1
1
1
1
0
1
1
0
0
0
0
0
1
1
0
0
0
0
1
0
0
1
0
0
0
0
1
0
1
0
0
1
1
1
1
0
1
0
1
0
1
0
1
1
0
1
0
1
1
1
1
1
1
0
0
0
1
1
0
0
1
0...

output:

? 1 2
? 2 3
? 3 4
? 4 5
? 1 5
? 2 5
? 1 4
? 2 4
? 2 5
? 3 5
? 2 4
? 3 4
? 3 5
? 4 5
? 3 4
? 4 5
? 4 6
? 5 6
? 4 5
? 6 7
? 1 7
? 2 7
? 1 6
? 2 6
? 2 7
? 3 7
? 2 6
? 3 6
? 3 7
? 4 7
? 3 6
? 4 6
? 5 7
? 6 7
? 5 6
? 4 7
? 5 7
? 4 6
? 5 6
? 6 7
? 8 9
? 8 9
? 8 10
? 9 10
? 8 9
? 10 11
? 11 12
? 12 13
? 13...

result:

wrong output format Unexpected end of file - int32 expected