結果

問題 No.583 鉄道同好会
ユーザー Bioinfo_KBioinfo_K
提出日時 2017-10-28 10:33:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 733 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 26,144 KB
最終ジャッジ日時 2024-05-01 20:33:12
合計ジャッジ時間 4,149 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
16,000 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 29 ms
10,624 KB
testcase_03 AC 28 ms
10,624 KB
testcase_04 AC 29 ms
10,624 KB
testcase_05 AC 29 ms
10,624 KB
testcase_06 WA -
testcase_07 AC 31 ms
10,752 KB
testcase_08 AC 30 ms
10,624 KB
testcase_09 AC 29 ms
10,624 KB
testcase_10 AC 30 ms
10,752 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

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)
l = 0
def DFS(v,p,d):
    visited[v] = True
    for e in mat[v]:
        if e != p and d<=m:
            DFS(e, v,d+1)
DFS(0,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