結果
| 問題 | No.2202 贅沢てりたまチキン |
| コンテスト | |
| ユーザー |
tamato
|
| 提出日時 | 2023-02-03 21:26:01 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 192 ms / 2,000 ms |
| コード長 | 1,380 bytes |
| 記録 | |
| コンパイル時間 | 151 ms |
| コンパイル使用メモリ | 85,120 KB |
| 実行使用メモリ | 87,936 KB |
| 最終ジャッジ日時 | 2026-03-24 03:13:02 |
| 合計ジャッジ時間 | 3,375 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 28 |
ソースコード
mod = 998244353
def main():
import sys
input = sys.stdin.readline
class UnionFind():
def __init__(self, n):
self.n = n
self.root = [-1] * (n + 1)
self.rnk = [0] * (n + 1)
def find_root(self, x):
while self.root[x] >= 0:
x = self.root[x]
return x
def unite(self, x, y):
x = self.find_root(x)
y = self.find_root(y)
if x == y:
return
elif self.rnk[x] > self.rnk[y]:
self.root[x] += self.root[y]
self.root[y] = x
else:
self.root[y] += self.root[x]
self.root[x] = y
if self.rnk[x] == self.rnk[y]:
self.rnk[y] += 1
def isSameGroup(self, x, y):
return self.find_root(x) == self.find_root(y)
def size(self, x):
return -self.root[self.find_root(x)]
N, M = map(int, input().split())
UF = UnionFind(N * 2)
for _ in range(M):
a, b = map(int, input().split())
UF.unite(a, b + N)
UF.unite(a + N, b)
ok = 1
for v in range(1, N + 1):
if not UF.isSameGroup(v, v+N):
ok = 0
break
if ok:
print("Yes")
else:
print("No")
if __name__ == '__main__':
main()
tamato