結果

問題 No.2202 贅沢てりたまチキン
ユーザー ああいいああいい
提出日時 2023-02-04 16:05:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 432 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 1,322 ms
コンパイル使用メモリ 86,720 KB
実行使用メモリ 82,892 KB
最終ジャッジ日時 2023-09-16 12:45:36
合計ジャッジ時間 6,533 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,312 KB
testcase_01 AC 70 ms
71,232 KB
testcase_02 AC 69 ms
71,424 KB
testcase_03 AC 70 ms
70,892 KB
testcase_04 AC 70 ms
71,028 KB
testcase_05 AC 71 ms
71,148 KB
testcase_06 AC 71 ms
71,080 KB
testcase_07 AC 69 ms
71,276 KB
testcase_08 AC 70 ms
71,084 KB
testcase_09 AC 69 ms
71,224 KB
testcase_10 AC 73 ms
74,336 KB
testcase_11 AC 71 ms
71,080 KB
testcase_12 AC 70 ms
71,188 KB
testcase_13 AC 70 ms
71,256 KB
testcase_14 AC 193 ms
80,528 KB
testcase_15 AC 187 ms
80,560 KB
testcase_16 AC 183 ms
80,412 KB
testcase_17 AC 192 ms
80,360 KB
testcase_18 AC 140 ms
78,788 KB
testcase_19 AC 140 ms
80,524 KB
testcase_20 AC 218 ms
81,668 KB
testcase_21 AC 212 ms
82,088 KB
testcase_22 AC 183 ms
77,428 KB
testcase_23 AC 256 ms
79,908 KB
testcase_24 AC 231 ms
79,404 KB
testcase_25 AC 432 ms
82,892 KB
testcase_26 AC 196 ms
80,736 KB
testcase_27 AC 185 ms
80,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10 ** 8)

N,M = map(int,input().split())

C = 2 * N
parent = [-1] * C
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:return False
    if parent[I] < parent[J]:
        I,J = J,I
    parent[J] += parent[I]
    parent[I] = J
    return True
def isSame(i,j):
    return find(i) == find(j)
for _ in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    unite(a,b + N)
    unite(a + N,b)
for i in range(N):
    if find(i) != find(i + N):
        print('No')
        exit()
print('Yes')
0