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],p[110000];
vector<ll> a;
ll f(ll y)
{
ll l=0,r=L,z,i;
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);
for(i=0;i<=z;i++)
{
ri[i]=min(ri[i],mid-1);
}
for(i=z+1;i<n;i++)
{
le[i]=max(le[i],mid);
}
if(z<=y-1)
{
l=mid;
}
else
r=mid-1;
}
mid=(l+r+1)/2;
b[y]=mid;
return mid;
}
vector<int> find_routers(int l, int N, int q) {
L=l;
n=N;
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++)
{
b[p[i]]=f(p[i]);
for(j=0;j<p[i];j++)
{
ri[j]=min(ri[j],b[p[i]]);
}
for(j=p[i]+1;j<n;j++)
{
le[j]=max(le[j],b[p[i]]+1);
}
}
for(i=1;i<n;i++)
{
a[i]=a[i-1]+2*(b[i]-a[i-1]);
}
return a;
}
# | 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... |