# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
883534 | ibm2006 | Finding Routers (IOI20_routers) | C++17 | 0 ms | 0 KiB |
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<bits/stdc++.h>
#include "routers.h"
using namespace std;
typedef int ll;
ll n,i,j,k,L,l,r,x,y,z,w,le[110000],ri[110000],b[110000];
vector<ll> a;
ll f(ll x,ll y)
{
ll l=x,r=L,z;
l=max(l,le[y]);
r=min(r,ri[y]);
ll mid=(l+r+1)/2;
while(l<r)
{
mid=(l+r+1)/2;
z=use_detector(mid);
ri[z]=min(ri[z],mid-1);
le[z-1]=min(le[z-1],mid);
if(z==y-1)
{
l=mid;
}
else
r=mid-1;
}
mid=(l+r+1)/2;
b[y]=mid;
return (mid-x)*2+x;
}
vector<int> find_routers(int l, int n, int q) {
L=l;
a.resize(n);
for(i=0;i<n;i++)
ri[i]=l;
srand(time(NULL));
for(i=1;i<n;i++)
{
p[i]=i;
}
random_shuffle(p+1,p+n);
for(i=1;i<n;i++)
{
a[p[i]]=f(a[p[i]-1],p[i]);
}
return a;
}