結果

問題 No.2072 Anatomy
ユーザー 沙耶花沙耶花
提出日時 2022-09-16 21:27:58
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 745 bytes
コンパイル時間 3,924 ms
使用メモリ 17,144 KB
最終ジャッジ日時 2023-01-11 05:58:29
合計ジャッジ時間 7,922 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
4,904 KB
testcase_01 AC 1 ms
5,152 KB
testcase_02 AC 1 ms
4,908 KB
testcase_03 AC 1 ms
5,152 KB
testcase_04 AC 1 ms
4,904 KB
testcase_05 AC 2 ms
4,904 KB
testcase_06 AC 2 ms
4,904 KB
testcase_07 AC 2 ms
5,152 KB
testcase_08 AC 112 ms
14,920 KB
testcase_09 AC 121 ms
16,032 KB
testcase_10 AC 114 ms
11,824 KB
testcase_11 AC 120 ms
14,908 KB
testcase_12 AC 93 ms
11,232 KB
testcase_13 AC 126 ms
16,824 KB
testcase_14 AC 80 ms
10,532 KB
testcase_15 AC 76 ms
11,628 KB
testcase_16 AC 126 ms
16,788 KB
testcase_17 AC 127 ms
16,504 KB
testcase_18 AC 64 ms
10,144 KB
testcase_19 AC 129 ms
17,140 KB
testcase_20 AC 130 ms
17,104 KB
testcase_21 AC 125 ms
17,064 KB
testcase_22 AC 132 ms
17,088 KB
testcase_23 AC 128 ms
17,004 KB
testcase_24 AC 124 ms
17,036 KB
testcase_25 AC 133 ms
17,144 KB
testcase_26 AC 2 ms
5,152 KB
testcase_27 AC 129 ms
17,068 KB
testcase_28 AC 128 ms
17,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001



int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<vector<int>> a(N);
	rep(i,N){
		a[i].push_back(i);
	}
	
	dsu D(N);
	int ans = 0;
	vector<int> x(M),y(M);
	rep(i,M){
		cin>>x[i]>>y[i];
		x[i]--,y[i]--;
	}
	vector<int> cnt(N,0);
	for(int i=M-1;i>=0;i--){
		int X = D.leader(x[i]),Y=  D.leader(y[i]);
		if(X==Y){
			cnt[X]++;
		}
		else{
			D.merge(X,Y);
			int Z = D.leader(x[i]);
			cnt[Z] = max(cnt[X],cnt[Y])+1;
		}
	}
	rep(i,N){
		ans = max(ans,cnt[i]);
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}
0