# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
792675 | caganyanmaz | Rail (IOI14_rail) | C++14 | 358 ms | 648 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 <bits/stdc++.h>
#include "rail.h"
using namespace std;
int n;
int f;
int* v;
int* t;
constexpr static int MXSIZE = 5000;
constexpr static int MXDIST = 1e6;
bitset<MXSIZE> found;
int data[MXSIZE][2]; // minindex, mindist
void findLocation(int N, int first, int location[], int stype[])
{
n = N;
f = first;
v = location;
t = stype;
v[0] = f;
t[0] = 1;
for (int i = 1; i < n; i++)
data[i][1] = MXDIST;
vector<int> s(1, 0);
found[0] = true;
while (s.size() < n)
{
for (int i = 0; i < n; i++)
{
if(found[i])
continue;
int dist = getDistance(s.back(), i);
if (dist < data[i][1])
{
data[i][0] = s.back();
data[i][1] = dist;
}
}
int mn = -1;
for (int i = 0; i < n; i++)
if (!found[i] && (mn == -1 || data[i][1] < data[mn][1]))
mn = i;
if (t[data[mn][0]] == 1)
{
v[mn] = v[data[mn][0]] + data[mn][1];
t[mn] = 2;
}
else
{
v[mn] = v[data[mn][0]] - data[mn][1];
t[mn] = 1;
}
found[mn] = true;
s.push_back(mn);
}
}
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... |