QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#662768 | #4831. Eager Sorting | rotcar07 | 0 | 0ms | 0kb | C++23 | 706b | 2024-10-21 10:12:02 | 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!