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 "rail.h"
#include <bits/stdc++.h>
using namespace std;
void findLocation(int n, int first, int location[], int stype[]){
location[0] = first;
stype[0] = 1;
vector<vector<int>> dist(n, vector<int>(n));
for (int i = 0; i < n; ++i){
for (int j = i+1; j < n; ++j) dist[i][j] = dist[j][i] = getDistance(i, j);
}
vector<pair<int, int>> d0(n-1);
for (int i = 1; i < n; ++i) d0[i-1] = {dist[0][i], i};
sort(d0.begin(), d0.end());
vector<int> v1, v2;
for (int i = 0; i < n-1; ++i){
int dd = d0[i].first;
int cur = d0[i].second;
location[cur] = first + dd;
stype[cur] = 2;
bool f1 = true, f2 = false;
for (auto x : v1) {
if (dist[x][cur] < dd) {
dd -= dist[0][x];
location[cur] = location[x] - dd;
stype[cur] = 1;
f1 = false;
break;
}
}
if (location[cur] < first) {
f2 = true;
for (auto x : v2) {
if (dist[x][cur] < dd) {
dd = d0[i].first - dist[0][x];
location[cur] = location[x] + dd;
stype[cur] = 2;
f2 = false;
break;
}
}
}
if (f2) v2.push_back(cur);
else if (f1) v1.push_back(cur);
}
}
# | 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... |