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;
#define ll long long
#define pb push_back
const int maxn = 5e3 + 20;
int d[maxn][maxn];
int get(int i , int j)
{
if(i != j && !d[i][j])
d[i][j] = d[j][i] = getDistance(i , j);
return d[i][j];
}
void findLocation(int N, int first, int location[], int stype[])
{
int n = N;
vector<pair<int , int> > tmp;
for(int i = 1; i < n; i++)
tmp.pb({get(0 , i) , i});
sort(tmp.begin() , tmp.end());
vector<int> rd;
for(auto x : tmp)
{
int v = x.second;
bool bad = 0;
if(!rd.empty())
{
int lx = get(0 , rd.back()) - get(rd.back() , v);
int tmp = -1;
for(auto u : rd)
if(get(0 , u) >= lx)
{
tmp = u;
break;
}
if(get(0 , v) == get(v , tmp) + get(tmp , 0))
bad = 1;
}
if(!bad)
location[v] = get(0 , v) , rd.pb(v) , stype[v] = 2;
else
stype[v] = 1 , location[v] = get(0 , rd.back()) - get(rd.back() , v);
}
for(int i = 0; i < n; i++)
location[i] += first;
stype[0] = 1;
}
# | 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... |