이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "rail.h"
using namespace std;
int distFrom0[5001];
int distFromMin[5001];
int queries[5001][5001];
int closest[5001];
int minDists[5001];
bool doneWith[5001];
void findLocation(int n, int first, int location[], int sType[]) {
location[0] = first;
sType[0] = 1;
doneWith[0] = true;
for (int i = 0; i < n; i++)
{
for (int j = i+1; j < n; j++)
{
queries[i][j] = getDistance(i,j);
queries[j][i] = queries[i][j];
}
}
for (int i = 0; i < n; i++)
{
minDists[i] = 1000000007;
for (int j = 0; j < n; j++)
{
if (j != i and queries[i][j] < minDists[i])
{
minDists[i] = queries[i][j];
closest[i] = j;
}
}
}
for (int i = 0; i < n; i++)
{
cout << closest[i] << " ";
}
cout << "\n";
int otherIndex = closest[0];
sType[otherIndex] = 2;
location[otherIndex] = first + queries[0][otherIndex];
doneWith[otherIndex] = true;
for (int i = 0; i < n; i++)
{
if (!doneWith[i])
{
if (queries[i][0] < queries[i][otherIndex])
{
if (closest[i] == 0 or queries[i][0] < queries[closest[i]][0])
{
sType[i] = 2;
location[i] = location[0] + queries[i][0];
}
else
{
sType[i] = 1;
location[i] = location[0] + queries[i][0] - 2*minDists[i];
}
}
else
{
if (closest[i] == otherIndex or queries[i][otherIndex] < queries[closest[i]][otherIndex])
{
sType[i] = 1;
location[i] = location[otherIndex] - queries[i][otherIndex];
}
else
{
sType[i] = 2;
location[i] = location[otherIndex] - queries[i][otherIndex] + 2*minDists[i];
}
}
}
}
}
# | 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... |