結果
問題 | No.1639 最小通信路 |
ユーザー |
|
提出日時 | 2021-08-06 21:49:50 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 820 bytes |
コンパイル時間 | 4,467 ms |
コンパイル使用メモリ | 310,796 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-17 01:43:29 |
合計ジャッジ時間 | 7,512 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 RE * 22 |
ソースコード
#include <atcoder/all>#include <bits/stdc++.h>#include <cmath>using namespace std;using namespace atcoder;using ll = long long;#define all(A) A.begin(),A.end()using vll = vector<ll>;#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)using Graph = vector<vector<ll>>;Graph G;vll E;vector<bool> seen;ll k = 0;void dfs(int v) {seen[v] = true; // v を訪問済にする// v から行ける各頂点 next_v についてE[v] = k;for (auto next_v : G[v]) {if (seen[next_v]) continue; // next_v が探索済だったらスルーk++;dfs(next_v); // 再帰的に探索}E[v] = k - E[v];}int main() {ll N;cin >> N;dsu D(N);while (1) {ll A, B, C;cin >> A >> B >> C;A--; B--;D.merge(A, B);if (D.size(A) == N) {cout << C << endl;return 0;}}}