# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
102770 | naoai | Rail (IOI14_rail) | C++14 | 3039 ms | 254840 KiB |
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;
const int nmax = 5000;
bool fix[nmax + 1];
int v[nmax + 1], tip[nmax + 1];
int mn[nmax + 1];
vector<pair<int, int>> d[nmax + 1];
void findLocation(int N, int first, int location[], int stype[]) {
for (int i = 0; i < N; ++ i)
for (int j = i + 1; j < N; ++ j) {
int x = getDistance(i, j);
d[i].push_back({x, j});
d[j].push_back({x, i});
}
for (int i = 0; i < N; ++ i)
sort(d[i].begin(), d[i].end());
v[0] = first;
tip[0] = 1;
fix[0] = 1;
for (int step = 0; step < N - 1; ++ step) {
int x, y, e = 1 << 30;
x = y = -1;
for (int i = 0; i < N; ++ i) {
if (fix[i] == 1) {
while (mn[i] < d[i].size() && fix[d[i][mn[i]].second] == 1)
++ mn[i];
if (mn[i] < d[i].size() && d[i][mn[i]].first < e) {
x = i;
y = d[i][mn[i]].second;
e = d[i][mn[i]].first;
}
}
}
if (tip[x] == 1) {
v[y] = v[x] + e;
tip[y] = 2;
} else {
v[y] = v[x] - e;
tip[y] = 1;
}
fix[y] = 1;
}
for (int i = 0; i < N; ++ i) {
location[i] = v[i];
stype[i] = tip[i];
}
}
Compilation message (stderr)
# | 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... |