結果
| 問題 |
No.1473 おでぶなおばけさん
|
| コンテスト | |
| ユーザー |
Example0911
|
| 提出日時 | 2021-04-09 21:48:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 174 ms / 2,000 ms |
| コード長 | 930 bytes |
| コンパイル時間 | 2,105 ms |
| コンパイル使用メモリ | 203,704 KB |
| 最終ジャッジ日時 | 2025-01-20 14:03:39 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 47 |
ソースコード
#include "bits/stdc++.h"
//#define int long long
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 61);
ll mod = 1000000007;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n, m;
cin >> n >> m;
vector<vector<pair<ll, ll>>>G(n);
for (int i = 0; i < m; i++) {
ll s, t, d; cin >> s >> t >> d; s--; t--;
G[s].push_back({ t, d });
G[t].push_back({ s, d });
}
ll l = -1, r = 1001001001001;
ll ans = 0;
while (r - l > 1) {
ll mid = (l + r) / 2;
queue<ll>q;
vector<ll>now(n, -1);
q.push(0);
now[0] = 0;
while (!q.empty()) {
ll p = q.front(); q.pop();
for (auto nv : G[p]) {
ll to = nv.first, tmp = nv.second;
if (tmp < mid)continue;
if (now[to] != -1)continue;
now[to] = now[p] + 1;
q.push(to);
}
}
if (now[n - 1] == -1)r = mid;
else {
l = mid;
ans = now[n - 1];
}
}
cout << l << " " << ans << endl;
return 0;
}
Example0911