Submission #751645

#TimeUsernameProblemLanguageResultExecution timeMemory
751645JooDdae버스 (JOI14_bus)C++17
0 / 100
309 ms22972 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = 1e9; int n, m, q, in[300300]; priority_queue<array<int, 3>, vector<array<int, 3>>, greater<>> pq; vector<array<int, 2>> v[100100]; int main(){ cin.tie(0)->sync_with_stdio(0); cin >> n >> m; for(int i=1;i<=m;i++) { int a, b, c, d; cin >> a >> b >> c >> d; pq.push({c, i, a}), pq.push({d, -i, b}); } memset(in, -1, sizeof in); while(!pq.empty()) { auto [t, id, u] = pq.top(); pq.pop(); if(id < 0) { id = -id; if(in[id] < 0 || (!v[u].empty() && v[u].back()[1] >= in[id])) continue; v[u].push_back({t, in[id]}); } else { if(v[u].empty()) { if(u == 1) in[id] = t; continue; } in[id] = v[u].back()[1]; } } cin >> q; while(q--) { int x; cin >> x; auto it = lower_bound(v[n].begin(), v[n].end(), array<int, 2>({x, INF})); cout << (it == v[n].begin() ? -1 : (*prev(it))[1]) << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...