QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#662768#4831. Eager Sortingrotcar070 0ms0kbC++23706b2024-10-21 10:12:022024-10-21 10:12:02

Judging History

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

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

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;
				 if(!~z) exit(0);
            swap(b[i],i);
        }
    }
    cout<<"-1 -1"<<endl;
}

详细

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: