結果
| 問題 | No.583 鉄道同好会 | 
| コンテスト | |
| ユーザー |  lllllll88938494 | 
| 提出日時 | 2022-09-17 13:14:53 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 152 ms / 2,000 ms | 
| コード長 | 521 bytes | 
| コンパイル時間 | 196 ms | 
| コンパイル使用メモリ | 81,920 KB | 
| 実行使用メモリ | 80,384 KB | 
| 最終ジャッジ日時 | 2024-12-22 00:43:08 | 
| 合計ジャッジ時間 | 2,395 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 16 | 
ソースコード
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')
    
            
            
            
        