結果
問題 | No.2072 Anatomy |
ユーザー |
![]() |
提出日時 | 2022-09-18 22:23:26 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 453 ms / 2,000 ms |
コード長 | 438 bytes |
コンパイル時間 | 241 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 100,796 KB |
最終ジャッジ日時 | 2024-12-22 01:41:40 |
合計ジャッジ時間 | 8,476 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
def root(x):if P[x] < 0:return xelse:P[x] = root(P[x])return P[x]def unite(x, y):x = root(x)y = root(y)if x == y:P[x] -= 1returnif x > y: x,y = y,xP[x] = min(P[x], P[y]) - 1P[y] = xN, M = map(int, input().split())UV = [list(map(int, input().split())) for _ in range(M)]P = [-1] * (N + 1)for u, v in reversed(UV):unite(u, v)print(- P[1] - 1)