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 "rail.h"
#include <bits/stdc++.h>
using namespace std;
int dis[5010][5010];
void findLocation(int n, int first, int loc[], int type[])
{
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
dis[i][j] = getDistance(i,j);
loc[0]=first, type[0]=1;
int num = 0, mn = 1000000;
for(int i = 1; i < n; i++)
if(dis[0][i]<mn) mn=dis[0][i],num=i;
loc[num] = loc[0]+mn, type[num]=2;
for(int i = 1; i < n; i++)
if(i!=num) type[i]=(dis[0][i]==dis[0][num]+dis[num][i])?1:2;
for(int i = 1; i < n; i++)
if(type[i]==2) loc[i] = loc[0]+dis[0][i];
for(int i = 1; i < n; i++)
if(type[i]==1) loc[i] = loc[0]-(dis[0][i]-dis[0][num]*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... |