이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rail.h"
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define REP(i,n) for(int i = 0; i < n; i ++)
#define FOR(i,a,b) for(int i = a; i < b; i ++)
#define all(v) v.begin(),v.end()
int dist[5005][5005];
void findLocation(int N, int first, int location[], int stype[]){
REP(i,N){
dist[i][i] = 0;
FOR(j,i+1,N){
dist[i][j] = getDistance(i,j);
dist[j][i] = dist[i][j];
}
}
int mn = 1;
FOR(i,2,N){
if(dist[0][mn] > dist[0][i]) mn = i;
}
location[0] = first;
stype[0] = 1;
location[mn] = first+dist[0][mn];
stype[mn] = 2;
vector<pii> lft,rgt;
FOR(i,1,N){
if(i != mn){
if(dist[0][i] == dist[0][mn]+dist[mn][i]) lft.pb({dist[mn][i],i});
else rgt.pb({dist[0][i],i});
}
}
sort(all(lft));
sort(all(rgt));
int prevC = 0,prevD = mn;
for(auto x:lft){
if(dist[x.S][prevC] == dist[x.S][prevD]+dist[prevC][prevD]){
location[x.S] = location[prevD]-dist[prevD][x.S];
stype[x.S] = 1;
prevC = x.S;
}
else{
location[x.S] = location[prevC]+dist[prevC][x.S];
stype[x.S] = 2;
prevD = x.S;
}
}
prevC = 0,prevD = mn;
for(auto x:rgt){
if(dist[x.S][prevD] == dist[x.S][prevC]+dist[prevC][prevD]){
location[x.S] = location[prevC]+dist[prevC][x.S];
stype[x.S] = 2;
prevD = x.S;
}
else{
location[x.S] = location[prevD]-dist[prevC][x.S];
stype[x.S] = 1;
prevC= x.S;
}
}
}
# | 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... |