Submission #1010731

#TimeUsernameProblemLanguageResultExecution timeMemory
1010731gmroh06버스 (JOI14_bus)C++17
100 / 100
178 ms27532 KiB
#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; }

Compilation message (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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...