結果
問題 | No.583 鉄道同好会 |
ユーザー |
![]() |
提出日時 | 2018-07-18 22:03:40 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 502 ms / 2,000 ms |
コード長 | 640 bytes |
コンパイル時間 | 164 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 17,920 KB |
最終ジャッジ日時 | 2024-12-16 08:54:21 |
合計ジャッジ時間 | 4,008 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
N,M = map(int,input().split()) stn_list = [[] for i in range(N)] stn_count = [0 for i in range(N)] def checklink(n): if stn_list[n]==[]: return target = stn_list[n][:] stn_list[n] = [] for i in target: checklink(i) for i in range(M): s,t = map(int,input().split()) stn_list[s].append(t) stn_list[t].append(s) stn_count[s] += 1 stn_count[t] += 1 checklink(s) for i in stn_list: if i != []: print("NO") exit(0) count = 0 for i in range(N): if stn_count[i]%2 == 1: count += 1 if count>2: print("NO") exit(0) print("YES")