제출 #705292

#제출 시각아이디문제언어결과실행 시간메모리
705292ThegeekKnight16Rail (IOI14_rail)C++17
30 / 100
248 ms98392 KiB
#include <bits/stdc++.h>
#include "rail.h"
using namespace std;
const int MAXN = 5e3 + 10;
int Dist[MAXN][MAXN];

void findLocation(int N, int first, int location[], int stype[])
{
    location[0] = first; stype[0] = 1;

    // Rever na ultima parcial
    for (int i = 0; i < N; i++)
    {
        for (int j = i+1; j < N; j++)
        {
            Dist[i][j] = Dist[j][i] = getDistance(i, j);
        }
    }

    int leastDistant = 1;
    for (int i = 1; i < N; i++) if (Dist[0][i] < Dist[0][leastDistant]) leastDistant = i;
    location[leastDistant] = first + Dist[0][leastDistant]; stype[leastDistant] = 2;


    for (int i = 1; i < N; i++)
    {
        if (i == leastDistant) continue;

        if (Dist[0][i] < Dist[leastDistant][i])
        {
            location[i] = location[0] + Dist[0][i];
            stype[i] = 2;
        }
        else
        {
            location[i] = location[leastDistant] - Dist[leastDistant][i];
            stype[i] = 1;
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...