結果
| 問題 |
No.1610 She Loves Me, She Loves Me Not, ...
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-12 20:42:55 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 107 ms / 2,000 ms |
| コード長 | 861 bytes |
| コンパイル時間 | 437 ms |
| コンパイル使用メモリ | 82,916 KB |
| 実行使用メモリ | 78,452 KB |
| 最終ジャッジ日時 | 2025-11-12 20:43:00 |
| 合計ジャッジ時間 | 4,367 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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()