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 "rail.h"
using namespace std;
#define mp make_pair
#define fr first
#define sc second
long long d[2],nn[2],wg[2][100069];
pair<long long,long long> as[100069];
void findLocation(int n,int st,int sq[],int kd[])
{
long long i,k,w,w2,w3,w4,w5,p;
for(i=1;i<n;i++)
{
as[i]={getDistance(0,i),i};
}
sort(as+1,as+n);
sq[0]=st;
kd[0]=1;
for(i=1;i<n;i++)
{
w=as[i].fr;
k=as[i].sc;
if(nn[0])
{
w2=getDistance(d[0],k);
}
w3=wg[0][nn[0]];
w4=w3-(w3+w2-w)/2;
p=lower_bound(wg[0]+1,wg[0]+nn[0]+1,w4)-wg[0];
if(!nn[0]||p>nn[0]||wg[0][p]!=w4)
{
sq[k]=st+w;
kd[k]=2;
d[0]=k;
nn[0]++;
wg[0][nn[0]]=w;
}
else
{
if(p>1)
{
sq[k]=st+w3-w2;
kd[k]=1;
}
else
{
if(nn[1])
{
w2=getDistance(d[1],k);
}
w3=wg[1][nn[1]];
w4=w3-(w3+w2-w)/2;
p=lower_bound(wg[1]+1,wg[1]+nn[1]+1,w4)-wg[1];
w5=wg[0][1];
if(!nn[1]||p>nn[1]||wg[1][p]!=w4)
{
sq[k]=st+w5-(w-w5);
kd[k]=1;
d[1]=k;
nn[1]++;
wg[1][nn[1]]=w;
}
else
{
sq[k]=st+w5-(w3-w2-w5);
kd[k]=2;
}
}
}
}
}
Compilation message (stderr)
rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:33:12: warning: 'w2' may be used uninitialized in this function [-Wmaybe-uninitialized]
33 | w4=w3-(w3+w2-w)/2;
| ~~^~~
# | 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... |