이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
inline void fastio() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
}
int main() {
    fastio();
    ll n, m, q;
    cin >> n >> m;
    vector<vector<tuple<ll, ll, ll>>> gr(n + 1);
    for (ll i = 0, u, v, x, y; i < m; i++) {
        cin >> u >> v >> x >> y;
        gr[v].emplace_back(u, y, x);
    }
    for (ll i = 1; i <= n; i++) {
        sort(gr[i].begin(), gr[i].end(), [&](const auto& x, const auto& y) -> bool {
            return get<1>(x) < get<1>(y);
        });
    }
    auto cal = [&](ll s) -> ll {
        static vector<ll> dp(n + 1, -1), idx(n + 1);
        priority_queue<pair<ll, ll>> pq;
        pq.emplace(dp[n] = s, n);
        while (!pq.empty()) {
            auto [cur, loc] = pq.top();
            pq.pop();
            if (cur != dp[loc]) {
                continue;
            }
            for (ll& i = idx[loc]; i < gr[loc].size(); idx[loc]++) {
                auto [nxt, x, y] = gr[loc][i];
                if (x > dp[loc]) {
                    break;
                }
                if (dp[nxt] < y) {
                    pq.emplace(dp[nxt] = y, nxt);
                }
            }
        }
        return dp[1];
    };
    cin >> q;
    vector<pair<ll, ll>> query(q);
    vector<ll> ans(q);
    for (ll i = 0; i < q; i++) {
        cin >> query[i].first;
        query[i].second = i;
    }
    sort(query.begin(), query.end());
    for (auto& [x, idx] : query) {
        ans[idx] = cal(x);
    }
    for (auto& x : ans) {
        cout << x << '\n';
    }
    return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
bus.cpp: In lambda function:
bus.cpp:46:38: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::tuple<long long int, long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |             for (ll& i = idx[loc]; i < gr[loc].size(); idx[loc]++) {
      |                                    ~~^~~~~~~~~~~~~~~~| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |