結果
| 問題 | No.3490 最高経路問題 |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-04-28 00:03:35 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,176 bytes |
| 記録 | |
| コンパイル時間 | 3,700 ms |
| コンパイル使用メモリ | 346,780 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-28 00:03:48 |
| 合計ジャッジ時間 | 10,820 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = (a); i < (b); i++)
mt19937 rng(random_device{}());
struct DSU {
vi par, cnt;
DSU(int N): par(N), cnt(N, 1) {
iota(all(par), 0);
}
int root(int x) {
if (par[x] == x) return x;
return par[x] = root(par[x]);
}
int merge(int x, int y) {
x = root(x), y = root(y);
if (x == y) return 0;
if (cnt[x] < cnt[y]) swap(x, y);
par[y] = x;
cnt[x] += cnt[y];
return 1;
}
};
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, m;
cin >> n >> m;
vector<tuple<int, int, int>> edges;
for (int i = 0; i < m; i++) {
int a, b, w;
cin >> a >> b >> w;
a--,b--;
edges.emplace_back(w, a, b);
}
sort(begin(edges), end(edges));
DSU dsu(n);
for (auto [w, a, b]: edges) {
if (dsu.merge(a, b)) {
if (dsu.root(0) == dsu.root(n - 1)) {
cout << w << endl;
return 0;
}
}
}
cout << "NaN" << endl;
}
vjudge1