結果
問題 | No.1473 おでぶなおばけさん |
ユーザー |
![]() |
提出日時 | 2021-04-09 22:32:31 |
言語 | C++17(clang) (17.0.6 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,357 bytes |
コンパイル時間 | 2,211 ms |
コンパイル使用メモリ | 124,416 KB |
実行使用メモリ | 8,240 KB |
最終ジャッジ日時 | 2024-06-25 06:09:30 |
合計ジャッジ時間 | 8,059 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 52 ms
5,376 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 57 ms
5,376 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | AC | 75 ms
5,376 KB |
testcase_42 | AC | 75 ms
5,376 KB |
testcase_43 | AC | 90 ms
6,624 KB |
testcase_44 | AC | 90 ms
6,756 KB |
testcase_45 | AC | 90 ms
6,632 KB |
testcase_46 | AC | 100 ms
6,844 KB |
testcase_47 | AC | 120 ms
7,640 KB |
testcase_48 | AC | 111 ms
7,584 KB |
ソースコード
#include <iostream> #include <vector> #include <queue> const int INF = 1000111000; int bfs(const std::vector<std::vector<std::pair<int, int>>> &graph, int from, int to, int weight) { std::vector<int> distances(graph.size(), INF); std::queue<int> queue; distances[from] = 0; queue.push(from); while (!queue.empty()) { int v = queue.front(); queue.pop(); for (auto p : graph[v]) { if (p.second >= weight && distances[p.first] == INF) { distances[p.first] = distances[v] + 1; queue.push(p.first); } } } return distances[to]; } int main() { int n, m; std::cin >> n >> m; std::vector<std::vector<std::pair<int, int>>> graph(n, std::vector<std::pair<int, int>>()); for (size_t i = 0; i < m; i++) { int s, t, d; std::cin >> s >> t >> d; s--; t--; graph[s].push_back(std::make_pair(t, d)); } int ok = 1; int ng = 1000000001; while (std::abs(ok - ng) > 1) { int mid = (ok + ng) / 2; int dist = bfs(graph, 0, n - 1, mid); if (dist < INF) { ok = mid; } else { ng = mid; } } std::cout << ok << ' ' << bfs(graph, 0, n - 1, ok) << std::endl; }