結果
問題 | No.1449 新プロランド |
ユーザー |
|
提出日時 | 2021-03-31 15:56:17 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,275 bytes |
コンパイル時間 | 2,137 ms |
コンパイル使用メモリ | 106,388 KB |
最終ジャッジ日時 | 2025-01-20 02:00:12 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'void solve()': main.cpp:34:14: error: 'std::tuple<int, int, int> <structured bindings>' has incomplete type 34 | using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>; | ^~~~~~~~~ In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/vector:64, from /Users/tiramister/CompetitiveProgramming/Cpp/CppLibrary/Graph/graph.hpp:3: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_vector.h: In instantiation of 'constexpr std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >]': /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_vector.h:528:7: required from 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue() [with _Seq = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Requires = void; _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::greater<std::tuple<int, int, int> >]' main.cpp:27:35: required from here /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_vector.h:367:49: error: invalid use of incomplete type 'class std::tuple<int, int, int>' 367 | _M_impl._M_end_of_storage - _M_impl._M_start); | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_algobase.h:64, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/vector:60: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_pair.h:90:11: note: declaration of 'class std::tuple<int, int, int>' 90 | class tuple; | ^~~~~ In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_p
ソースコード
#line 2 "/Users/tiramister/CompetitiveProgramming/Cpp/CppLibrary/Graph/graph.hpp"#include <vector>template <class Cost = int>struct Edge {int src, dst;Cost cost;Edge() = default;Edge(int src, int dst, Cost cost = 1): src(src), dst(dst), cost(cost){};bool operator<(const Edge<Cost>& e) const { return cost < e.cost; }bool operator>(const Edge<Cost>& e) const { return cost > e.cost; }};template <class Cost = int>struct Graph : public std::vector<std::vector<Edge<Cost>>> {using std::vector<std::vector<Edge<Cost>>>::vector;void span(bool direct, int src, int dst, Cost cost = 1) {(*this)[src].emplace_back(src, dst, cost);if (!direct) (*this)[dst].emplace_back(dst, src, cost);}};#line 2 "/Users/tiramister/CompetitiveProgramming/Cpp/CppLibrary/Tools/heap_alias.hpp"#include <queue>template <class T>using MaxHeap = std::priority_queue<T>;template <class T>using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;#line 3 "main.cpp"#include <iostream>#include <algorithm>#line 6 "main.cpp"using namespace std;constexpr int INF = 1 << 30;constexpr int C = 1000;void solve() {int n, m;cin >> n >> m;Graph<int> graph(n);while (m--) {int u, v, c;cin >> u >> v >> c;graph.span(false, --u, --v, c);}vector<int> ts(n);for (auto& t : ts) cin >> t;auto dp = vector(n, vector(C + 2, INF));// 食べた時間がCより大なら、移動時間は常に0なので区別不要MinHeap<tuple<int, int, int>> heap;// 時間, 頂点, おにぎり時間dp[0][ts[0]] = ts[0];heap.emplace(ts[0], 0, ts[0]);while (!heap.empty()) {auto [d, v, t] = heap.top();heap.pop();if (dp[v][t] < d) continue;for (auto e : graph[v]) {auto u = e.dst;auto nd = d + e.cost / t + ts[u];auto nt = min(C + 1, t + ts[u]);if (nd >= dp[u][nt]) continue;dp[u][nt] = nd;heap.emplace(nd, u, nt);}}cout << *min_element(dp[n - 1].begin(), dp[n - 1].end()) << "\n";}int main() {cin.tie(nullptr);ios::sync_with_stdio(false);solve();return 0;}