結果
| 問題 |
No.583 鉄道同好会
|
| コンテスト | |
| ユーザー |
ntuda
|
| 提出日時 | 2025-01-11 12:37:24 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 662 bytes |
| コンパイル時間 | 859 ms |
| コンパイル使用メモリ | 82,108 KB |
| 実行使用メモリ | 115,332 KB |
| 最終ジャッジ日時 | 2025-01-11 12:37:28 |
| 合計ジャッジ時間 | 3,442 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 RE * 1 |
ソースコード
import sys
sys.setrecursionlimit(12530)
N,M = map(int,input().split())
E = [[] for _ in range(N)]
D = [0] * N
for i in range(M):
a,b = map(int,input().split())
E[a].append((b,i))
E[b].append((a,i))
D[a] += 1
D[b] += 1
if i == 0:
s0 = a
cnt = 0
for i in range(N):
if D[i] % 2 == 1:
cnt += 1
s0 = i
if cnt > 2:
print("NO")
exit()
cnt = 0
def dfs(u):
global cnt
if cnt == M:
print("YES")
exit()
for v,id in E[u]:
if nu[id]:
nu[id] = 0
cnt += 1
dfs(v)
cnt -= 1
nu[id] = 1
nu = [1] * M
dfs(s0)
print("NO")
ntuda