# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
577601 | Belgutei | Rail (IOI14_rail) | C++17 | 71 ms | 468 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;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
int n;
int d[5005][5005];
int mn = 1e9, mx, x, y;
void findLocation(int N, int F, int location[], int stype[]) {
//getDistance(0,0);
n = N;
location[0] = F;
stype[0] = 1;
//
for(int i = 1; i < n; i ++) {
d[0][i] = getDistance(0,i);
if(mn > d[0][i]) {
mn = d[0][i];
x = i;
}
}
location[x] = F + mn;
stype[x] = 2;
//
mx = location[0];
y = 0;
for(int i = 0; i < n; i ++) {
if(i == 0 || i == x) continue;
d[x][i] = getDistance(x,i);
if(d[0][x] + d[x][i] == d[0][i]) {
location[i] = location[x] - d[x][i];
stype[i] = 1;
if(mx < location[i]) {
mx = location[i];
y = i;
}
}
}
//
for(int j = 0; j < n; j ++) {
if(j == 0 || j == x || j == y) continue;
if( d[0][j] + F == (d[x][j] - (location[x] - location[y]) * 2) + location[x] ) {
location[j] = d[0][j] + F;
stype[j] = 2;
}
}
mn = 1e9,mx = 0;;
int a,b;
for(int i = 0; i < n; i ++) {
if(stype[i] != 0 && mn > location[i]) {
mn = location[i];
a = i;
}
if(stype[i] != 0 && mx < location[i]) {
mx = location[i];
b = i;
}
}
for(int i = 0; i < n; i ++) {
if(stype[i] != 0) continue;
d[a][i] = getDistance(a,i);
int tmp = location[a] + d[a][i];
if(tmp < location[0]) {
location[i] = tmp;
stype[i] = 2;
}
}
for(int i = 0; i < n; i ++) {
if(stype[i] != 0) continue;
d[b][i] = getDistance(b,i);
int tmp = location[b] - d[b][i];
if(tmp > location[x]) {
location[i] = tmp;
stype[i] = 1;
}
}
return;
}
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... |