結果

問題 No.583 鉄道同好会
ユーザー GrayCoderGrayCoder
提出日時 2017-10-28 00:56:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 402 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 27,556 KB
最終ジャッジ日時 2024-05-01 18:23:36
合計ジャッジ時間 3,352 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
10,752 KB
testcase_01 AC 24 ms
10,752 KB
testcase_02 AC 26 ms
10,752 KB
testcase_03 AC 24 ms
10,752 KB
testcase_04 WA -
testcase_05 AC 24 ms
10,624 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 26 ms
10,624 KB
testcase_09 AC 26 ms
10,624 KB
testcase_10 AC 27 ms
10,752 KB
testcase_11 AC 125 ms
15,684 KB
testcase_12 AC 155 ms
17,056 KB
testcase_13 AC 153 ms
17,052 KB
testcase_14 AC 151 ms
17,044 KB
testcase_15 AC 190 ms
18,296 KB
testcase_16 AC 357 ms
25,200 KB
testcase_17 AC 412 ms
27,292 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N, M = map(int, input().split())
    T = {tuple(map(int, input().split())) for _ in [0] * M}

    if M == 1:
        print('YES')
        exit()

    station = [0] * N
    for a, b in T:
        station[a] += 1
        station[b] += 1

    cnt = tuple(filter(lambda n:n==2, station))
    if len(cnt) == M or len(cnt) == M - 1:
        print('YES')
    else:
        print('NO')

main()
0