結果

問題 No.2072 Anatomy
ユーザー suisui
提出日時 2022-09-16 22:33:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 1,449 bytes
コンパイル時間 4,052 ms
コンパイル使用メモリ 265,416 KB
実行使用メモリ 9,388 KB
最終ジャッジ日時 2023-08-23 16:09:39
合計ジャッジ時間 7,814 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 105 ms
8,492 KB
testcase_09 AC 109 ms
8,904 KB
testcase_10 AC 110 ms
9,252 KB
testcase_11 AC 112 ms
8,720 KB
testcase_12 AC 88 ms
7,788 KB
testcase_13 AC 117 ms
8,480 KB
testcase_14 AC 74 ms
6,268 KB
testcase_15 AC 70 ms
6,416 KB
testcase_16 AC 119 ms
8,644 KB
testcase_17 AC 117 ms
8,664 KB
testcase_18 AC 57 ms
5,884 KB
testcase_19 AC 122 ms
9,368 KB
testcase_20 AC 120 ms
8,692 KB
testcase_21 AC 115 ms
8,680 KB
testcase_22 AC 122 ms
8,556 KB
testcase_23 AC 119 ms
8,496 KB
testcase_24 AC 115 ms
9,388 KB
testcase_25 AC 123 ms
9,060 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 118 ms
8,556 KB
testcase_28 AC 117 ms
8,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n+1); i++)
#define repn(i,a,b) for (int i = (int)(a) ; i < (int)(b+1); i++)
#define repv(i, n) for (ll i = (ll)(n-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define cauto const auto&
#define bit(n) (1LL<<(n))
#define uni(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using P = pair<ll,ll>;
using PP = pair<int, P>;
using Graph = vector<vector<int>>;
using mint = modint998244353;
#ifdef LOCAL
    #include <debug.hpp>
    #define debug(...) debug::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
    #define debug(...) (static_cast<void>(0))
#endif

int main(){
    ll n,m;
    cin >> n >> m;
    vector<P> uv;
    rep(i,m){
        ll u,v;
        cin >> u >> v;
        u--; v--;
        uv.push_back({u,v});
    }
    dsu d(n);
    vector<ll> ans(n,0);
    repv(i,m){
        if(d.same(uv[i].first,uv[i].second)){
            ans[d.leader(uv[i].first)]++;
            continue;
        }
        ll tmp1 = d.leader(uv[i].first);
        ll tmp2 = d.leader(uv[i].second);
        d.merge(uv[i].first,uv[i].second);
        ans[d.leader(uv[i].first)] = max(ans[tmp1] ,ans[tmp2])+1;
    }
    cout << ans[d.leader(uv[0].first)] << endl;
    return 0;
}
0