제출 #1307229

#제출 시각아이디문제언어결과실행 시간메모리
1307229Leyna철로 (IOI14_rail)C++20
30 / 100
32 ms588 KiB
#include "rail.h"
#include <bits/stdc++.h>

using namespace std;

void findLocation(int N, int first, int location[], int stype[])
{
    location[0] = first;
    stype[0] = 1;
    if (N == 1) return;
    int dist[N];
    int minimum = 1e9;
    int min_idx = -1;
    for (int i=0; i<N; i++){
        dist[i] = getDistance(0, i);
        if (dist[i] > 0 && dist[i] < minimum){
            minimum = dist[i];
            min_idx = i;
        }
    }
    location[min_idx] = first + dist[min_idx];
    stype[min_idx] = 2;
    int dist1[N];
    for (int i=0; i<N; i++){
        dist1[i] = getDistance(min_idx, i);
        if (i == 0 || i == min_idx) continue;
        if (dist1[i] < dist[i]){
            // i ist Typ C --> links von 0
            stype[i] = 1;
            location[i] = location[min_idx] - dist1[i];
        }
        else if (dist1[i] > dist[i]){
            // i ist Typ D --> rechts von 0
            stype[i] = 2;
            location[i] = first + dist[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...