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 <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){
if (dists[i][cd] < dists[i][0]){ //left
location[i] = first+diff-dists[cd][i]; stype[i] = 1;
} else { //right
location[i] = first+dists[i][0]; stype[i] = 2;
}
/*if (dists[i][cd] < diff){
location[i] = location[cd]-dists[i][cd]; stype[i] = 1;
} else {
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 (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 (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... |