結果

問題 No.2072 Anatomy
ユーザー 沙耶花沙耶花
提出日時 2022-09-16 21:27:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 745 bytes
コンパイル時間 6,799 ms
コンパイル使用メモリ 261,356 KB
実行使用メモリ 17,304 KB
最終ジャッジ日時 2023-08-23 14:26:17
合計ジャッジ時間 9,900 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 114 ms
14,872 KB
testcase_09 AC 122 ms
16,084 KB
testcase_10 AC 115 ms
11,808 KB
testcase_11 AC 123 ms
14,852 KB
testcase_12 AC 94 ms
11,224 KB
testcase_13 AC 127 ms
16,700 KB
testcase_14 AC 81 ms
10,484 KB
testcase_15 AC 77 ms
11,388 KB
testcase_16 AC 129 ms
16,804 KB
testcase_17 AC 125 ms
16,392 KB
testcase_18 AC 65 ms
10,068 KB
testcase_19 AC 130 ms
17,104 KB
testcase_20 AC 133 ms
17,280 KB
testcase_21 AC 128 ms
17,304 KB
testcase_22 AC 131 ms
17,172 KB
testcase_23 AC 131 ms
16,876 KB
testcase_24 AC 127 ms
16,876 KB
testcase_25 AC 132 ms
16,880 KB
testcase_26 AC 2 ms
4,384 KB
testcase_27 AC 131 ms
17,276 KB
testcase_28 AC 130 ms
16,876 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