| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 995622 | gmroh06 | 버스 (JOI14_bus) | C++17 | 134 ms | 27732 KiB |
이 제출은 이전 버전의 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> mem(n + 1, -1), idx(n + 1);
priority_queue<pair<ll, ll>> pq;
pq.emplace(mem[n] = s, n);
while (!pq.empty()) {
auto [cur, loc] = pq.top();
pq.pop();
if (cur != mem[loc]) {
continue;
}
for (ll& i = idx[loc]; i < gr[loc].size(); idx[loc]++) {
auto [nxt, x, y] = gr[loc][i];
if (x > mem[loc]) {
break;
}
if (mem[nxt] < y) {
pq.emplace(mem[nxt] = y, nxt);
}
}
}
return mem[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) 메시지
| # | 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... | ||||
