Submission #700436

#TimeUsernameProblemLanguageResultExecution timeMemory
700436ForestedRail (IOI14_rail)C++17
30 / 100
85 ms720 KiB
#include "rail.h"

#include <bits/stdc++.h>
using namespace std;

using i32 = int;
using i64 = long long;
template <typename T>
using Vec = vector<T>;

#define OVERRIDE4(a, b, c, d, ...) d
#define REP2(i, n) for (i32 i = 0; i < (i32)(n); ++i)
#define REP3(i, m, n) for (i32 i = (i32)(m); i < (i32)(n); ++i)
#define REP(...) OVERRIDE4(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
#define ALL(x) begin(x), end(x)
#define PER(i, n) for (i32 i = (i32)(n) - 1; i >= 0; --i)

template <typename T>
bool chmin(T &x, const T &y) {
    if (x > y) {
        x = y;
        return true;
    } else {
        return false;
    }
}
template <typename T>
bool chmax(T &x, const T &y) {
    if (x < y) {
        x = y;
        return true;
    } else {
        return false;
    }
}

constexpr i32 INF = 1001001001;
constexpr i64 INF64 = 3003003003003003003;

void findLocation(int n, int first, int location[], int stype[]) {
    assert(n <= 100);
    i32 mn = INF, mn_idx = 0;
    REP(i, 1, n) {
        if (chmin(mn, getDistance(0, i))) {
            mn_idx = i;
        }
    }
    stype[0] = 1;
    location[0] = first;
    stype[mn_idx] = 2;
    location[mn_idx] = first + mn;
    REP(i, 1, n) {
        if (i != mn_idx) {
            i32 l = getDistance(0, i);
            i32 r = getDistance(mn_idx, i);
            if (l < r) {
                stype[i] = 2;
                location[i] = first + l;
            } else {
                stype[i] = 1;
                location[i] = first + mn - r;
            }
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...