結果
問題 |
No.1473 おでぶなおばけさん
|
ユーザー |
![]() |
提出日時 | 2022-03-23 13:30:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,025 bytes |
コンパイル時間 | 1,776 ms |
コンパイル使用メモリ | 176,996 KB |
実行使用メモリ | 11,820 KB |
最終ジャッジ日時 | 2024-10-11 11:14:31 |
合計ジャッジ時間 | 10,643 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 44 WA * 3 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:39, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54, from main.cpp:1: In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>]', inlined from 'int main()' at main.cpp:64:23: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:167:25: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized] 167 | { return _M_insert(__n); } | ~~~~~~~~~^~~~~ main.cpp: In function 'int main()': main.cpp:33:17: note: 'ans' was declared here 33 | int64_t ans; | ^~~
ソースコード
#include <bits/stdc++.h> using namespace std; struct Edge { int64_t to; // 辺の行先 int64_t weight; // 辺の重み Edge(int64_t t, int64_t w) : to(t), weight(w){} }; using Graph = vector<vector<Edge>>; int main() { int64_t N, M; cin >> N >> M; Graph G(N); int64_t S, T, D; for(int64_t i = 0; i < M; i++) { cin >> S >> T >> D; S--; T--; G[S].push_back(Edge(T, D)); G[T].push_back(Edge(S, D)); } int64_t ok = 1; int64_t ng = 1000000001; int64_t mid; const int64_t inf = 1000000001; queue<int64_t> q; int64_t ans; while(ng - ok != 1) { mid = (ng + ok) / 2; vector<int64_t> dist(N, inf); dist[0] = 0; q.push(0); while(!q.empty()) { int64_t p = q.front(); q.pop(); for(Edge e : G[p]) { if(e.weight < mid) continue; if(dist[p] + 1 < dist[e.to]) { dist[e.to] = dist[p] + 1; q.push(e.to); } } } if(dist[N - 1] != inf) { ok = mid; ans = dist[N - 1]; } else ng = mid; } cout << ok << ' ' << ans << endl; return 0; }