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 <bits/stdc++.h>
using namespace std;
map<int,int> found;
int use_detector1(int x)
{
    if(found.count(x))return found[x];
    auto it=found.lower_bound(x);
    if(it!=found.end()&&it!=found.begin())
    {
        int t1=(*it).second;
        it--;
        int t2=(*it).second;
        if(t1==t2)return t1;
    }
    int t=use_detector(x);
    found[x]=t;
    return t;
}
vector<int> find_routers(int l, int n, int q) {
    vector<int>r;
    r.push_back(0);
    for(int j=1;j<n;j++)
    {
        int last=r.back();
        int low=(last+2)/2,high=(l-l%2)/2-(n-j-1);
        int mid=(low+high)/2,ans;
        if(low==high)
        {
            ans=low*2;
        }
        else while(low<=high)
        {
            mid=(low+high)/2;
            if(use_detector1((mid*2+last)/2)==j-1)
            {
                ans=mid*2;
                low=mid+1;
            }
            else high=mid-1;
        }
        r.push_back(ans);
    }
    //for(int i=0;i<r.size();i++)cout<<r[i]<<" ";
    //cout<<endl;
    return r;
}
| # | 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... |