結果

問題 No.583 鉄道同好会
ユーザー GrayCoder
提出日時 2017-10-28 00:56:14
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 402 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 27,316 KB
最終ジャッジ日時 2024-11-22 00:07:17
合計ジャッジ時間 3,377 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 WA * 4
権限があれば一括ダウンロードができます

ソースコード

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