結果

問題 No.2202 贅沢てりたまチキン
ユーザー flygonflygon
提出日時 2023-02-03 21:33:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 495 ms / 2,000 ms
コード長 481 bytes
コンパイル時間 792 ms
コンパイル使用メモリ 86,848 KB
実行使用メモリ 92,436 KB
最終ジャッジ日時 2023-09-15 17:05:25
合計ジャッジ時間 6,580 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,108 KB
testcase_01 AC 71 ms
71,148 KB
testcase_02 AC 72 ms
71,104 KB
testcase_03 AC 72 ms
71,316 KB
testcase_04 AC 71 ms
71,208 KB
testcase_05 AC 71 ms
71,308 KB
testcase_06 AC 72 ms
70,904 KB
testcase_07 AC 72 ms
71,340 KB
testcase_08 AC 71 ms
71,332 KB
testcase_09 AC 74 ms
70,924 KB
testcase_10 AC 82 ms
80,564 KB
testcase_11 AC 71 ms
71,068 KB
testcase_12 AC 71 ms
71,316 KB
testcase_13 AC 72 ms
71,304 KB
testcase_14 AC 210 ms
88,908 KB
testcase_15 AC 211 ms
88,916 KB
testcase_16 AC 209 ms
89,020 KB
testcase_17 AC 207 ms
89,140 KB
testcase_18 AC 158 ms
86,232 KB
testcase_19 AC 166 ms
88,984 KB
testcase_20 AC 234 ms
88,272 KB
testcase_21 AC 229 ms
88,624 KB
testcase_22 AC 194 ms
77,540 KB
testcase_23 AC 278 ms
80,188 KB
testcase_24 AC 238 ms
77,988 KB
testcase_25 AC 495 ms
92,436 KB
testcase_26 AC 217 ms
89,232 KB
testcase_27 AC 208 ms
88,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())

p = [-1]*(2*n+10)
def find(x):
  if p[x] < 0:
    return x
  else:
    p[x] = find(p[x])
    return p[x]
def union(x,y):
  x = find(x)
  y = find(y)
  if x == y:
    return
  if p[x] > p[y]:
    x,y = y,x
  p[x] += p[y]
  p[y] = x


graph = [[] for i in range(n+1)]
for i in range(m):
  a,b = map(int,input().split())
  union(a, b+n)
  union(a+n, b)

ans = 1
for i in range(1,n+1):
  ans &= find(i) == find(i+n)

print('Yes') if ans else print('No')
0