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;
int l[5001],t[5001];
int d[5001][5001];
int minn[5001],vr[5001];
int n;
void rec(int v)
{
for(int i=0; i<n; i++)
{
if(t[i]||vr[i]!=v)continue;
if(t[v]==1)
{
l[i]=l[v]+d[v][i];
t[i]=2;
}
else
{
l[i]=l[v]-d[v][i];
t[i]=1;
}
rec(i);
}
}
void findLocation(int N, int first, int location[], int stype[])
{
n=N;
for(int i=0; i<N; i++)
minn[i]=1e9;
for(int i=0; i<N; i++)
{
for(int j=i+1; j<N; j++)
{
d[i][j]=getDistance(i,j);
//cout<<i<<" "<<j<<" "<<d[i][j]<<endl;
if(d[i][j]<minn[i])
{
//cout<<j<<endl;
minn[i]=d[i][j];
vr[i]=j;
}
if(d[i][j]<minn[j])
{
minn[j]=d[i][j];
vr[j]=i;
}
}
}
l[0]=first;
t[0]=1;
rec(0);
for(int i=0; i<n; i++)
{
location[i]=l[i],stype[i]=t[i];
//cout<<i<<" "<<l[i]<<" "<<t[i]<<" "<<vr[i]<<" "<<minn[i]<<endl;
}
}
# | 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... |