結果
| 問題 | No.1473 おでぶなおばけさん |
| コンテスト | |
| ユーザー |
Novi
|
| 提出日時 | 2021-04-12 22:03:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,907 bytes |
| 記録 | |
| コンパイル時間 | 3,466 ms |
| コンパイル使用メモリ | 238,320 KB |
| 実行使用メモリ | 11,968 KB |
| 最終ジャッジ日時 | 2024-06-28 17:38:49 |
| 合計ジャッジ時間 | 7,828 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 21 WA * 26 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define int ll
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define ALL(a) (a).begin(), (a).end()
template <class t, class u> void chmax(t& a, u b) {
if (a < b) a = b;
}
template <class t, class u> void chmin(t& a, u b) {
if (b < a) a = b;
}
template <class t> using vc = vector<t>;
template <class t> using vvc = vc<vc<t>>;
using pi = pair<int, int>;
using vi = vc<int>;
using uint = unsigned;
using ull = unsigned long long;
int popcount(signed t) { return __builtin_popcount(t); }
int popcount(ll t) { return __builtin_popcountll(t); }
bool ispow2(int i) { return i && (i & -i) == i; }
ll mask(int i) { return (ll(1) << i) - 1; }
int lcm(int a, int b) { return a / __gcd(a, b) * b; }
int n, m;
int cnt = 0;
vc<vc<pi>> G;
int bfs(int w, int st = 0, int dist = 0) {
vc<int> ch(100100, 1e18);
ch[st] = dist;
queue<pi> pq;
pq.push(pi(st, dist));
while (!pq.empty()) {
auto p = pq.front();
pq.pop();
auto now = p.first;
auto d = p.second;
for (auto u : G[now]) {
if (ch[u.first] > d + 1 && u.second >= w) {
ch[u.first] = d + 1;
pq.push(pi(u.first, d + 1));
}
}
}
return cnt = ch[n - 1];
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(20);
cin >> n >> m;
G.resize(n);
rep(i, m) {
int s, t, d;
cin >> s >> t >> d;
s--, t--;
G[s].emplace_back(t, d);
G[t].emplace_back(s, d);
}
int ng = 0LL;
int ok = 1e9 + 2;
while (abs(ok - ng) > 1) {
int mid = (ok + ng) / 2;
if (bfs(mid) == 1e18) {
ok = mid;
} else {
ng = mid;
}
}
cout << ng << " " << cnt << endl;
}
Novi