結果
問題 |
No.1473 おでぶなおばけさん
|
ユーザー |
![]() |
提出日時 | 2021-04-04 17:39:39 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,284 bytes |
コンパイル時間 | 997 ms |
コンパイル使用メモリ | 91,140 KB |
最終ジャッジ日時 | 2025-01-20 11:24:03 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 34 TLE * 13 |
ソースコード
// 解となる候補の値を大きい方から全部調べる // TLEになってほしい #include <algorithm> #include <iostream> #include <queue> #include <utility> #include <vector> using namespace std; int main() { cin.tie(nullptr), ios::sync_with_stdio(false); int N, M; cin >> N >> M; vector<vector<pair<int, int>>> to(N); vector<int> ds; for (int e = 0; e < M; e++) { int s, t, d; cin >> s >> t >> d; s--, t--; to[s].emplace_back(t, d); to[t].emplace_back(s, d); ds.push_back(d); } sort(ds.begin(), ds.end()); ds.erase(unique(ds.begin(), ds.end()), ds.end()); reverse(ds.begin(), ds.end()); vector<int> dist(N); for (auto ret : ds) { dist.assign(N, 1 << 30); dist[0] = 0; queue<int> q; q.push(0); while (!q.empty()) { int now = q.front(); q.pop(); for (auto [nxt, w] : to[now]) { if (w >= ret and dist[nxt] > dist[now] + 1) { dist[nxt] = dist[now] + 1; q.push(nxt); } } } if (dist.back() < 1 << 30) { cout << ret << ' ' << dist.back() << '\n'; return 0; } } }