結果

問題 No.583 鉄道同好会
ユーザー lllllll88938494lllllll88938494
提出日時 2022-09-17 13:14:21
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 521 bytes
コンパイル時間 544 ms
コンパイル使用メモリ 87,216 KB
実行使用メモリ 81,680 KB
最終ジャッジ日時 2023-08-23 17:40:40
合計ジャッジ時間 3,912 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

n,m=map(int,input().split())
stations = [[] for i in range(n)]
ans =[0]*n

for i in range(m):
    a,b=map(int,input().split())
    stations[a].append(b)
    stations[b].append(a)
    ans[a] = 1
    ans[b] = 1
    if i == 0:start = a
    

cnt=0
for i in stations:
    if len(i)%2 == 1:
        cnt+=1

f=[0]*n
def  dfs(x):
    for i in stations[x]:
        if f[i] == 0:
            f[i] = 1
            dfs(i)
f[start] = 1
dfs(start)

if (f == ans) and (cnt == 0 or cnt == 2):
    print('Yes')
else:
    print('No')
    
0