結果
| 問題 | No.1610 She Loves Me, She Loves Me Not, ... |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-12 20:42:55 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 108 ms / 2,000 ms |
| + 264µs | |
| コード長 | 861 bytes |
| 記録 | |
| コンパイル時間 | 250 ms |
| コンパイル使用メモリ | 95,976 KB |
| 実行使用メモリ | 86,292 KB |
| 最終ジャッジ日時 | 2026-07-16 11:29:16 |
| 合計ジャッジ時間 | 5,317 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
## https://yukicoder.me/problems/no/1610
from collections import deque
def main():
N, M = map(int, input().split())
next_nodes = [set() for _ in range(N)]
for _ in range(M):
a, b = map(int, input().split())
next_nodes[a - 1].add(b - 1)
next_nodes[b - 1].add(a - 1)
queue = deque()
for i in range(N):
if len(next_nodes[i]) == 1:
queue.append(i)
answer = 0
while len(queue) > 0:
v = queue.popleft()
if len(next_nodes[v]) == 0:
continue
answer += 1
for w in next_nodes[v]:
next_nodes[w].remove(v)
if len(next_nodes[w]) == 1:
queue.append(w)
next_nodes[v].clear()
if answer % 2 == 1:
print("Yes")
else:
print("No")
if __name__ == "__main__":
main()