QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#662762#4831. Eager Sortingrotcar070 0ms0kbC++23683b2024-10-21 10:09:062024-10-21 10:09:07

Judging History

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

  • [2024-10-21 10:09:07]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-10-21 10:09:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int b[105];
int main(){
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        int l=1,r=i,pos=i;
        while(l<r){
            int mid=l+r>>1;
            cout<<pos<<' '<<mid<<endl;
            int z;cin>>z;
            if(z==-1) exit(0);
            int zz=z^(pos>mid);
            if(z) swap(b[mid],b[pos]),pos=mid;
            if(zz) l=mid+1;
            else r=mid;
        }
        for(int j=1;j<=i;j++) if(b[j]>=r) b[j]++;
        b[pos]=r;
    }
    for(int i=1;i<=n;i++){
        if(b[i]!=i){
            int z;
            cin>>z;
            swap(b[i],i);
        }
    }
    cout<<"-1 -1"<<endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Instance #0 Time Limit Exceeded

Interactor to First Run

5
0
1
1
0
0
1
0

First Run to Interactor

2 1
3 2
2 1
4 2
4 3
5 3
3 2

Interactor to Second Run

5
0
0
0
0
0
1

Second Run to Interactor

2 1
3 2
4 2
4 3
5 3
5 4
-1 -1

Manager to Checker

OK
good job!

result: