結果

問題 No.583 鉄道同好会
ユーザー roarisroaris
提出日時 2019-08-04 20:09:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 470 bytes
コンパイル時間 114 ms
コンパイル使用メモリ 10,744 KB
実行使用メモリ 15,476 KB
最終ジャッジ日時 2023-09-23 01:05:13
合計ジャッジ時間 3,621 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,576 KB
testcase_01 AC 19 ms
8,592 KB
testcase_02 AC 19 ms
8,572 KB
testcase_03 AC 19 ms
8,460 KB
testcase_04 WA -
testcase_05 AC 18 ms
8,552 KB
testcase_06 AC 18 ms
8,508 KB
testcase_07 AC 18 ms
8,516 KB
testcase_08 AC 18 ms
8,508 KB
testcase_09 AC 19 ms
8,600 KB
testcase_10 AC 19 ms
8,640 KB
testcase_11 AC 104 ms
10,248 KB
testcase_12 AC 137 ms
10,836 KB
testcase_13 AC 137 ms
10,892 KB
testcase_14 AC 137 ms
10,888 KB
testcase_15 AC 174 ms
11,504 KB
testcase_16 AC 310 ms
14,388 KB
testcase_17 AC 376 ms
15,404 KB
testcase_18 AC 368 ms
15,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

N, M = map(int, input().split())
adj_dict = defaultdict(list)

for _ in range(M):
    Sa_i, Sb_i = map(int, input().split())
    adj_dict[Sa_i].append(Sb_i)
    adj_dict[Sb_i].append(Sa_i)

degree_even, degree_odd = 0, 0

for node in adj_dict:
    d = len(adj_dict[node])
    
    if d % 2 == 0:
        degree_even += 1
    else:
        degree_odd += 1

if degree_odd == 0 or degree_odd == 2:
    print('YES')
else:
    print('NO')
0