Submission #551558

#TimeUsernameProblemLanguageResultExecution timeMemory
551558AJ00Rail (IOI14_rail)C++17
0 / 100
306 ms98252 KiB
#include <bits/stdc++.h>
#include <rail.h>
using namespace std;
int dist[5000][5000];
void findLocation(int N, int first, int location[], int stype[]){
    int n = N;
    location[0] = first;
    stype[0] = 1;
    if (n == 1){
        return;
    }
    for (int i = 0; i < n; i++){
        stype[i] = -1;
        for (int j = i+1; j < n; j++){
            dist[i][j] = getDistance(i,j);
            dist[j][i] = dist[i][j];
        }
    }
    stype[0] = 1;
    for (int i = 0; i < n; i++){
        for (int j = i+1; j < n; j++){
            if (dist[0][i] == dist[0][j]+dist[i][j]){
                location[j] = dist[0][j]+location[0];
                location[i] = location[j]-dist[i][j];
                stype[j] = 2;
                stype[i] = 1;
            }
            else if (dist[0][j] == dist[0][i]+dist[i][j]){
                location[i] = dist[0][i]+location[0];
                location[j] = location[i]-dist[i][j];
                stype[i] = 2;
                stype[j] = 1;
            }
        }
    }
    for (int i = 0; i < n; i++){
        if (stype[i] == -1){
            location[i] = dist[0][i]+location[0];
            stype[i] = 2;
        }
    }
    return;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...