이 제출은 이전 버전의 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;
}
}
location[0] = first; stype[0] = 1;
location[cd] = first+diff; stype[cd] = 2;
for (int i = 1; i < n; i++){
if (i != cd){
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][0]){ //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_ -> 0 D
location[i] = first+diff-dists[i][cd]; stype[i] = 1;
}
} else { //right
if (mi == 0){
location[i] = first+dists[i][0]; stype[i] = 2;
} else if (dists[mi][0] < dists[i][0]){ // 0 D _C_ -> D
location[i] = first+dists[i][0]-mv; stype[i] = 1;
} else { // 0 D _D_
location[i] = first+dists[i][0]; 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... |