結果

問題 No.2072 Anatomy
ユーザー KudeKude
提出日時 2022-09-16 21:36:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 1,190 bytes
コンパイル時間 2,347 ms
コンパイル使用メモリ 228,024 KB
実行使用メモリ 6,260 KB
最終ジャッジ日時 2023-08-23 14:33:51
合計ジャッジ時間 4,693 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 39 ms
5,884 KB
testcase_09 AC 39 ms
5,888 KB
testcase_10 AC 40 ms
5,416 KB
testcase_11 AC 41 ms
5,968 KB
testcase_12 AC 32 ms
5,156 KB
testcase_13 AC 44 ms
6,260 KB
testcase_14 AC 28 ms
4,864 KB
testcase_15 AC 25 ms
4,880 KB
testcase_16 AC 44 ms
6,188 KB
testcase_17 AC 42 ms
5,888 KB
testcase_18 AC 22 ms
4,540 KB
testcase_19 AC 44 ms
6,256 KB
testcase_20 AC 45 ms
6,184 KB
testcase_21 AC 42 ms
6,148 KB
testcase_22 AC 45 ms
6,144 KB
testcase_23 AC 42 ms
6,260 KB
testcase_24 AC 41 ms
6,204 KB
testcase_25 AC 44 ms
6,232 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 43 ms
6,144 KB
testcase_28 AC 41 ms
6,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic pop
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;

} int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<P> es(m);
  for(auto& [u, v]: es) cin >> u >> v, u--, v--;
  reverse(all(es));
  dsu d(n);
  VI h(n);
  for(auto [u, v]: es) {
    int lu = d.leader(u), lv = d.leader(v);
    if (lu == lv) {
      h[lu]++;
    } else {
      int l = d.merge(lu, lv);
      h[l] = max(h[lu], h[lv]) + 1;
    }
  }
  int ans = *max_element(all(h));
  cout << ans << '\n';
}
0