結果

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

ソースコード

diff #

import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,m = Is()

mat = [[] for _ in range(n)]
for _ in range(m):
    a,b = Is()
    mat[a].append(b)
    mat[b].append(a)

visited = [False]*(n)
def DFS(v,p):
    visited[v] = True
    for e in mat[v]:
        if visited[e] == False:
            DFS(e, v)
DFS(0,0)

odd = 0 
for i,e in enumerate(mat):
    if len(e) > 0:
        if visited[i] == False:
            print("NO")
            exit()
        elif len(e) % 2 == 1:
            odd += 1

if odd <= 2:
    print("YES")
else:
    print("NO")
0