이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include "rail.h"
using namespace std;
int n, dists[5000][5000] = {};
void findLocation(int N, int first, int location[], int stype[]){
n = N;
for (int i = 0; i < n; i++){
for (int j = i+1; j < n; j++){
dists[i][j] = getDistance(i, j); dists[j][i] = dists[i][j];
}
}
int diff = 10000000, cd = -1;
for (int i = 1; i < n; i++){
if (dists[0][i] < diff){
diff = dists[0][i]; cd = i;
}
}
int td = diff, cc = -1;; diff = 10000000;
for (int i = 0; i < n; i++){
if (i != cd && dists[cd][i] < diff){
diff = dists[cd][i]; cc = i;
}
}
location[0] = first; stype[0] = 1;
location[cd] = first+td; stype[cd] = 2;
location[cc] = location[cd] - diff; stype[cc] = 1;
for (int i = 1; i < n; i++){
if (i != cd && i != cc){
int mv = 10000000, mi = -1;
for (int j = 0; j < n; j++){
if (j != i && dists[i][j] < mv){
mv = dists[i][j]; mi = j;
}
}
if (dists[i][cd] < dists[i][cc]){ //left
if (mi == cd){
location[i] = first+diff-dists[i][cd]; stype[i] = 1;
} else if (dists[mi][cd] < dists[i][cd]){ // C <- _D_ 0 D
location[i] = first+diff-dists[mi][cd]+mv; stype[i] = 2;
} else { // _C_ -> D 0 D
location[i] = first+diff-dists[i][cd]; stype[i] = 1;
}
} else { //right
if (mi == cc){
location[i] = first+dists[i][cc]; stype[i] = 2;
} else if (dists[mi][cc] < dists[i][cc]){ // 0 D _C_ -> D
location[i] = first+dists[mi][cc]-mv; stype[i] = 1;
} else { // 0 D C _D_
location[i] = first+dists[i][cc]; stype[i] = 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... |