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 all(fl) fl.begin(),fl.end()
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pli pair<long long,int>
#define gcd __gcd
#define lcm(x,y) x*y/__gcd(x,y)
#define pil pair<int,long long>
const int maxn=5e3+9;
long long d0[maxn];
int id[maxn];
long long d[maxn][maxn];
void findLocation(int n, int first, int location[], int stype[]){
for1(i,1,n-1)d[0][i]=getDistance(0,i),id[i]=i,d[i][0]=d[0][i];
location[0]=first,stype[0]=0;
sort(id,id+n,[](int i,int j){
return d[0][i]<d[0][j];
});
for1(i,1,n-1){
int u=id[i];
int best=0;
for1(j,1,i-1){
int val=getDistance(id[j],u);
d[id[j]][u]=val;
d[u][id[j]]=val;
if (val<d[best][u]){
best=id[j];
}
}
stype[u]=(stype[best]^1);
if (stype[best]==1)location[u]=location[best]-d[best][u];
else location[u]=location[best]+d[best][u];
}
for1(i,0,n-1)stype[i]++;
}
# | 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... |