제출 #1188177

#제출 시각아이디문제언어결과실행 시간메모리
1188177anmattroiRoller Coaster Railroad (IOI16_railroad)C++17
0 / 100
171 ms16080 KiB
#include "railroad.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define maxn 200005
using namespace std;
using ii = pair<int, int>;

template <class T> inline constexpr void cmin(T &x, const T &y) {if (x > y) x = y;}

struct node {
    int S, T, idx;
    node() {}
    node(int _S, int _T, int _idx) : S(_S), T(_T), idx(_idx) {}

    bool operator < (const node &other) const {
        if (S != other.S) return S < other.S;
        if (T != other.T) return T < other.T;
        return idx < other.idx;
    }
};


long long plan_roller_coaster(vector<int> s, vector<int> t) {
    int n = s.size();
    set<node> a, b;
    for (int i = 0; i < n; i++)
        if (s[i] <= t[i]) a.insert({s[i], t[i], i});
        else b.insert({s[i], t[i], i});

    int last = INT_MIN;
    while (1) {
        if (a.empty()) break;
        auto it = a.lower_bound(node(last, 0, 0));
        if (it == a.end()) {
            if (b.empty()) break;
            auto ti = b.lower_bound(node(last, 0, 0));
            if (it == b.end()) break;
            auto [S, T, idx] = *ti;
            b.erase(ti);
            last = T;
            continue;
        }
        int nexS = it->S;
        auto ti = b.lower_bound(node(last, 0, 0));
        if (ti != b.end() && ti->S < it->T) {
            b.erase(ti);
            last = ti->T;
            continue;
        }
        last = it->T;
        a.erase(it);
    }
    return !a.empty();
}

컴파일 시 표준 에러 (stderr) 메시지

railroad.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
railroad_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...