結果
| 問題 |
No.1610 She Loves Me, She Loves Me Not, ...
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-08 11:55:04 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 53 ms / 2,000 ms |
| コード長 | 1,280 bytes |
| コンパイル時間 | 293 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 12,672 KB |
| 最終ジャッジ日時 | 2024-09-29 18:45:55 |
| 合計ジャッジ時間 | 2,684 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
def main():
N, M = map(int, input().split())
graph = [set() for _ in range(N)]
degrees = [0] * N
for _ in range(M):
A, B = map(lambda n: int(n) - 1, input().split())
graph[A].add(B)
graph[B].add(A)
removable_edges = set()
for idx, neighbors in enumerate(graph):
if len(neighbors) != 1:
continue
for neighbor in neighbors:
removable_edges.add((min(idx, neighbor), max(idx, neighbor)))
ctr = 0
while removable_edges:
cur_edge = removable_edges.pop()
graph[cur_edge[0]].remove(cur_edge[1])
graph[cur_edge[1]].remove(cur_edge[0])
ctr += 1
if len(graph[cur_edge[0]]) == 1:
for neighbor in graph[cur_edge[0]]:
removable_edges.add(
(min(
cur_edge[0], neighbor), max(
cur_edge[0], neighbor)))
if len(graph[cur_edge[1]]) == 1:
for neighbor in graph[cur_edge[1]]:
removable_edges.add(
(min(
cur_edge[1], neighbor), max(
cur_edge[1], neighbor)))
if ctr % 2:
print("Yes")
else:
print("No")
if __name__ == "__main__":
main()