結果

問題 No.2072 Anatomy
ユーザー ああいいああいい
提出日時 2022-09-17 23:23:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 437 ms / 2,000 ms
コード長 687 bytes
コンパイル時間 503 ms
コンパイル使用メモリ 86,712 KB
実行使用メモリ 94,124 KB
最終ジャッジ日時 2023-08-23 17:55:59
合計ジャッジ時間 9,022 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,212 KB
testcase_01 AC 71 ms
71,076 KB
testcase_02 AC 74 ms
71,140 KB
testcase_03 AC 77 ms
71,044 KB
testcase_04 AC 72 ms
71,332 KB
testcase_05 AC 75 ms
70,896 KB
testcase_06 AC 73 ms
71,032 KB
testcase_07 AC 74 ms
71,212 KB
testcase_08 AC 437 ms
92,196 KB
testcase_09 AC 224 ms
89,808 KB
testcase_10 AC 357 ms
92,032 KB
testcase_11 AC 280 ms
91,852 KB
testcase_12 AC 248 ms
87,944 KB
testcase_13 AC 337 ms
93,032 KB
testcase_14 AC 306 ms
86,736 KB
testcase_15 AC 194 ms
85,628 KB
testcase_16 AC 371 ms
93,764 KB
testcase_17 AC 261 ms
92,136 KB
testcase_18 AC 186 ms
85,572 KB
testcase_19 AC 349 ms
94,124 KB
testcase_20 AC 413 ms
94,040 KB
testcase_21 AC 225 ms
91,632 KB
testcase_22 AC 341 ms
93,632 KB
testcase_23 AC 227 ms
91,772 KB
testcase_24 AC 225 ms
91,748 KB
testcase_25 AC 335 ms
93,556 KB
testcase_26 AC 71 ms
71,144 KB
testcase_27 AC 225 ms
91,420 KB
testcase_28 AC 335 ms
93,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10 ** 8)

N,M = map(int,input().split())
edge = []
for _ in range(M):
    u,v = map(int,input().split())
    edge.append((u-1,v-1))

parent = [-1] * N
dat = [0] * N
def find(i):
    if parent[i] < 0:
        return i
    parent[i] = find(parent[i])
    return parent[i]
def unite(i,j):
    I = find(i)
    J = find(j)
    if I == J:
        dat[I] += 1
        return False
    if parent[I] < parent[J]:
        I,J = J,I
    u = max(dat[I],dat[J])
    parent[J] += parent[I]
    parent[I] = J
    dat[J] = u + 1
    return True
def isSame(i,j):
    return find(i) == find(j)

ans = 0

for u,v in reversed(edge):
    unite(u,v)
ans = max(dat)
print(ans)
0