結果

問題 No.2072 Anatomy
ユーザー ああいいああいい
提出日時 2022-09-17 23:19:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 438 ms / 2,000 ms
コード長 618 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 82,476 KB
実行使用メモリ 191,860 KB
最終ジャッジ日時 2024-06-01 15:19:55
合計ジャッジ時間 8,110 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,108 KB
testcase_01 AC 43 ms
52,212 KB
testcase_02 AC 45 ms
54,368 KB
testcase_03 AC 44 ms
55,176 KB
testcase_04 AC 41 ms
53,136 KB
testcase_05 AC 43 ms
54,436 KB
testcase_06 AC 42 ms
54,232 KB
testcase_07 AC 46 ms
60,920 KB
testcase_08 AC 412 ms
89,960 KB
testcase_09 AC 213 ms
89,004 KB
testcase_10 AC 391 ms
90,812 KB
testcase_11 AC 266 ms
90,036 KB
testcase_12 AC 255 ms
87,488 KB
testcase_13 AC 300 ms
90,868 KB
testcase_14 AC 320 ms
85,312 KB
testcase_15 AC 192 ms
86,272 KB
testcase_16 AC 420 ms
92,204 KB
testcase_17 AC 244 ms
91,224 KB
testcase_18 AC 188 ms
84,108 KB
testcase_19 AC 313 ms
91,572 KB
testcase_20 AC 354 ms
91,312 KB
testcase_21 AC 273 ms
116,352 KB
testcase_22 AC 374 ms
91,308 KB
testcase_23 AC 270 ms
117,660 KB
testcase_24 AC 253 ms
107,580 KB
testcase_25 AC 249 ms
90,544 KB
testcase_26 AC 37 ms
52,704 KB
testcase_27 AC 438 ms
191,860 KB
testcase_28 AC 282 ms
90,668 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
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:
        parent[I] -= 1
        return False
    t = min(parent[I],parent[J])
    parent[I] = J
    parent[J] = t - 1
    return True
def isSame(i,j):
    return find(i) == find(j)

ans = 0

for u,v in reversed(edge):
    unite(u,v)
ans = min(parent)
print(-ans - 1)
0