結果
問題 |
No.583 鉄道同好会
|
ユーザー |
![]() |
提出日時 | 2017-10-28 10:33:05 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 733 bytes |
コンパイル時間 | 168 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 64,512 KB |
最終ジャッジ日時 | 2024-11-22 02:56:04 |
合計ジャッジ時間 | 22,448 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 WA * 2 TLE * 7 |
ソースコード
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")