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, fr, sm, sc;
int a[1010][1010];
int getmn(int aa)
{
int mn = INT_MAX, ret = aa;
for (int i = 0; i < n; i++)
{
if(aa == i) continue;
if(a[aa][i] < mn) mn = a[aa][i], ret = i;
}
return ret;
}
void findLocation(int N, int first, int location[], int stype[])
{
n = N;
fr = first;
for (int i = 0; i < n; i++)
{
for(int j = i + 1; j < n; ++j) a[i][j] = a[j][i] = getDistance(i, j);
}
stype[0] = 1, location[0] = first;
if(n == 1) return;
sm = getmn(0), sc = a[0][sm] + fr;
for (int i = 1; i < n; i++)
{
int ss = getmn(i);
if(ss == 0) stype[i] = 2, location[i] = fr + a[0][i];
else if(ss == sm) stype[i] = 1, location[i] = sc - a[sm][i];
else{
if(a[0][sm] + a[sm][i] == a[0][i])
{
if(a[sm][ss] + a[ss][i] == a[sm][i]) stype[i] = 2, location[i] = sc - a[sm][ss] + a[ss][i];
else stype[i] = 1, location[i] = sc - a[sm][i];
}
else
{
if(a[0][ss] + a[ss][i] == a[0][i]) stype[i] = 1, location[i] = fr + a[0][ss] - a[ss][i];
else stype[i] = 2, location[i] = fr + a[0][i];
}
}
}
return;
}
# | 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... |