結果
問題 | No.2805 Go to School |
ユーザー | risujiroh |
提出日時 | 2024-07-12 22:54:24 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 295 ms / 2,000 ms |
コード長 | 3,616 bytes |
コンパイル時間 | 3,461 ms |
コンパイル使用メモリ | 268,508 KB |
実行使用メモリ | 23,784 KB |
最終ジャッジ日時 | 2024-07-16 01:41:13 |
合計ジャッジ時間 | 8,894 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 3 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 84 ms
17,536 KB |
testcase_05 | AC | 118 ms
14,060 KB |
testcase_06 | AC | 71 ms
9,156 KB |
testcase_07 | AC | 56 ms
9,052 KB |
testcase_08 | AC | 96 ms
14,364 KB |
testcase_09 | AC | 69 ms
9,196 KB |
testcase_10 | AC | 54 ms
9,124 KB |
testcase_11 | AC | 295 ms
20,800 KB |
testcase_12 | AC | 172 ms
14,548 KB |
testcase_13 | AC | 249 ms
18,552 KB |
testcase_14 | AC | 30 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,944 KB |
testcase_17 | AC | 2 ms
6,944 KB |
testcase_18 | AC | 99 ms
11,364 KB |
testcase_19 | AC | 71 ms
8,844 KB |
testcase_20 | AC | 163 ms
15,732 KB |
testcase_21 | AC | 252 ms
20,616 KB |
testcase_22 | AC | 104 ms
10,752 KB |
testcase_23 | AC | 159 ms
14,196 KB |
testcase_24 | AC | 158 ms
14,304 KB |
testcase_25 | AC | 43 ms
8,732 KB |
testcase_26 | AC | 173 ms
23,784 KB |
testcase_27 | AC | 96 ms
17,400 KB |
testcase_28 | AC | 10 ms
7,296 KB |
testcase_29 | AC | 16 ms
8,192 KB |
testcase_30 | AC | 49 ms
12,992 KB |
testcase_31 | AC | 82 ms
10,560 KB |
testcase_32 | AC | 116 ms
18,724 KB |
testcase_33 | AC | 173 ms
19,752 KB |
testcase_34 | AC | 2 ms
6,944 KB |
testcase_35 | AC | 2 ms
6,940 KB |
testcase_36 | AC | 81 ms
8,976 KB |
testcase_37 | AC | 97 ms
10,624 KB |
testcase_38 | AC | 189 ms
16,360 KB |
ソースコード
#if __INCLUDE_LEVEL__ == 0 #include __BASE_FILE__ namespace { void Solve() { Int n, m, L, S, E; Scan(n, m, L, S, E); std::vector<std::vector<std::pair<Int, Int>>> g(n); while (m--) { Int a, b, t; Scan(a, b, t); --a, --b; g[a].emplace_back(b, t); g[b].emplace_back(a, t); } std::vector d(2, std::vector<Int>(n, INF)); for (Int z : Rep(2)) { Int s = z * (n - 1); for (std::priority_queue q(std::greater{}, std::vector{std::pair{d[z][s] = 0, s}}); Sz(q);) { auto [di, i] = q.top(); q.pop(); if (di != d[z][i]) { continue; } for (auto [j, t] : g[i]) { if (Chmin(d[z][j], di + t)) { q.emplace(d[z][j], j); } } } } Int ans = INF; while (L--) { Int i; Scan(i); --i; if (d[0][i] < S + E) { Chmin(ans, std::max(d[0][i], S) + 1 + d[1][i]); } } if (ans == INF) { ans = -1; } Print(ans); } } // namespace int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout << std::setprecision(std::numeric_limits<Float>::max_digits10); Solve(); } #else // __INCLUDE_LEVEL__ #include <bits/stdc++.h> using Int = int64_t; using Float = double; namespace ranges = std::ranges; namespace views = std::views; inline constexpr auto Rev = views::reverse; inline constexpr auto Map = views::transform; inline constexpr auto Filter = views::filter; constexpr auto Rep(Int l, Int r) { return views::iota(std::min(l, r), r); } constexpr auto Rep(Int n) { return Rep(0, n); } constexpr auto Rep1(Int l, Int r) { return Rep(l, r + 1); } constexpr auto Rep1(Int n) { return Rep(1, n + 1); } constexpr Int Sz(auto&& r) { return static_cast<Int>(ranges::size(r)); } template <class T, class U = T> bool Chmin(T& x, U&& y) { return y < x && (x = std::forward<U>(y), true); } template <class T, class U = T> bool Chmax(T& x, U&& y) { return x < y && (x = std::forward<U>(y), true); } inline constexpr Int INF = [] { std::array<char, sizeof(Int)> a; a.fill(0x3f); return std::bit_cast<Int>(a); }(); template <class T> concept Range = ranges::range<T> && !std::convertible_to<T, std::string_view>; template <class T> concept TupleLike = std::__is_tuple_like<T>::value && !Range<T>; namespace std { istream& operator>>(istream& is, Range auto&& r) { for (auto&& e : r) { is >> e; } return is; } istream& operator>>(istream& is, TupleLike auto&& t) { return apply([&](auto&... xs) -> istream& { return (is >> ... >> xs); }, t); } ostream& operator<<(ostream& os, Range auto&& r) { for (string_view sep = ""; auto&& e : r) { os << exchange(sep, " ") << e; } return os; } ostream& operator<<(ostream& os, TupleLike auto&& t) { const auto f = [&](auto&... xs) -> ostream& { [[maybe_unused]] string_view sep = ""; ((os << exchange(sep, " ") << xs), ...); return os; }; return apply(f, t); } } // namespace std #define DEF_INC_OR_DEC(op) \ auto& operator op(Range auto&& r) { \ for (auto&& e : r) { \ op e; \ } \ return r; \ } \ auto& operator op(TupleLike auto&& t) { \ std::apply([](auto&... xs) { (op xs, ...); }, t); \ return t; \ } DEF_INC_OR_DEC(++) DEF_INC_OR_DEC(--) #undef DEF_INC_OR_DEC void Scan(auto&&... xs) { std::cin >> std::tie(xs...); } void Print(auto&&... xs) { std::cout << std::tie(xs...) << '\n'; } template <class F> class Fix { public: explicit Fix(F f) : f_(std::move(f)) {} decltype(auto) operator()(auto&&... xs) const { return f_(std::ref(*this), std::forward<decltype(xs)>(xs)...); } private: F f_; }; #endif // __INCLUDE_LEVEL__