# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
405249 | blue | 철로 (IOI14_rail) | C++17 | 0 ms | 0 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 <iostream>
#include <vector>
using namespace std;
/*
Subtask 2
*/
int dist[100][100];
void findLocation(int n, int first, int location[], int stype[])
{
location[0] = first;
stype[0] = 1;
if(n == 1)
return;
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
dist[i][j] = getDistance(i, j);
int sort0[n];
for(int i = 0; i < n; i++)
sort0[i] = i;
sort(sort0, sort0+n, [] (int x, int y)
{
return dist[0][x] < dist[0][y];
});
int firstRight = sort0[1];
location[firstRight] = first + dist[0][firstRight];
stype[firstRight] = 2;
for(int i = 1; i < n; i++)
{
if(i == firstRight) continue;
if(dist[0][i] == dist[0][firstRight] + dist[firstRight][i])
{
stype[i] = 1;
location[i] = first + dist[0][firstRight] - dist[firstRight][i];
}
else
{
stype[i] = 2;
location[i] = first + dist[0][i];
}
}
cerr << "\n";
for(int i = 0; i < n; i++) cerr << stype[i] << ' ' << location[i] << '\n';
}
/*
Subtask 1
void findLocation(int n, int first, int location[], int stype[])
{
location[0] = first;
stype[0] = 1;
for(int i = 1; i < n; i++)
{
location[i] = first + getDistance(0, i);
stype[i] = 2;
}
cerr << '\n';
for(int i = 0; i < n; i++)
{
cerr << location[i] << ' ' << stype[i] << '\n';
}
}
*/