結果

問題 No.1639 最小通信路
ユーザー hayatenhayaten
提出日時 2021-08-07 00:21:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 1,578 bytes
コンパイル時間 12,831 ms
コンパイル使用メモリ 476,832 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 05:57:24
合計ジャッジ時間 15,345 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 6 ms
4,348 KB
testcase_03 AC 22 ms
4,348 KB
testcase_04 AC 19 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 5 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 5 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 4 ms
4,348 KB
testcase_17 AC 5 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 3 ms
4,348 KB
testcase_20 AC 5 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 3 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 3 ms
4,348 KB
testcase_26 AC 3 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 7 ms
4,348 KB
testcase_30 AC 10 ms
4,348 KB
testcase_31 AC 3 ms
4,348 KB
testcase_32 AC 8 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 7 ms
4,348 KB
testcase_35 AC 16 ms
4,348 KB
testcase_36 AC 7 ms
4,348 KB
testcase_37 AC 9 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 3 ms
4,348 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 3 ms
4,348 KB
testcase_42 AC 10 ms
4,348 KB
testcase_43 AC 3 ms
4,348 KB
testcase_44 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma region Macros
// #pragma GCC target("avx2")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define popcount(bit) __builtin_popcount(bit)
#define popcountll(bit) __builtin_popcountll(bit)
#define pb push_back
#define eb emplace_back
using namespace std;
using namespace atcoder;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Graph = vector<vector<int>>;
using boost::multiprecision::cpp_int;
using PS = pair<P, cpp_int>;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int fx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int fy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll INF = (1LL <<60);

int main() {
  int n;
  cin >> n;
  int N = (n * (n - 1)) / 2;
  vector<PS> res(N);
  dsu d(n);
  rep(i, N){
    int a, b;
    cpp_int x;
    cin >> a >> b >> x;
    res[i].first = {a, b};
    res[i].second = x;
  }
  cpp_int ans = 0;
  rep(i, N){
    int a = res[i].first.first;
    int b = res[i].first.second;
    a--, b--;
    cpp_int c = res[i].second;
    if(d.same(a, b))continue;
    d.merge(a, b);
    chmax(ans, c);
    if(d.size(a)== n){
      cout << ans << endl;
      return 0;
    }
  }
}
0