This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "routers.h"
#include <iostream>
#include <vector>
using namespace std;
vector<int> find_routers(int l, int n, int q) {
vector<int> ans;
ans.push_back(0);
int prev = 0, check = 0, mid = 0, lo =0, hi = l, c =0;
int found = 0;
for(int next=1; next<n; next++){
lo = ans[next-1], hi = l;
found =0;
while(!found){
mid = lo + (hi-lo)/2;
check = use_detector(mid);
//cout<<lo<<" "<<hi<<" "<<mid<<" "<<check<<" "<<prev<<"\n";
if(check == prev){
c = use_detector(mid+1);
if(c == next){
ans.push_back(mid*2 - ans[next-1]);
lo = mid+1;
prev = next;
found =1;
}
}
else{
hi = mid;
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |