Submission #598887

#TimeUsernameProblemLanguageResultExecution timeMemory
598887proma철로 (IOI14_rail)C++17
30 / 100
76 ms976 KiB
#include "rail.h"
#include <bits/stdc++.h>

using namespace std;

int d[105][105];

void findLocation(int N, int first, int location[], int stype[]) {
    for (int i = 0; i < N; i ++) {
        d[i][i] = 0;
        for (int j = i + 1; j < N; j ++) {
            d[i][j] = d[j][i] = getDistance(i, j);
        }
    }
    int nxt = -1, mn = 1e9;
    for (int i = 1; i < N; i ++) {
        if (mn > d[0][i]) {
            mn = d[0][i];
            nxt = i;
        }
    }
    stype[0] = 1;
    location[0] = first;
    stype[nxt] = 2;
    location[nxt] = first + mn;
    for (int i = 1; i < N; i ++) {
        if (i == nxt) continue;
        if (d[0][i] == d[0][nxt] + d[nxt][i]) {
            stype[i] = 1;
            location[i] = first - d[0][i] + 2 * d[0][nxt];
        }
        else {
            stype[i] = 2;
            location[i] = first + d[0][i];
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...