QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#662761 | #4831. Eager Sorting | rotcar07 | 0 | 0ms | 0kb | C++23 | 651b | 2024-10-21 10:07:59 | 2024-10-21 10:07:59 |
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;
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
Second Run to Interactor
Manager to Checker
WA array is not sorted!