結果

問題 No.583 鉄道同好会
ユーザー KoshStormKoshStorm
提出日時 2017-10-28 18:27:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 780 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 12,928 KB
最終ジャッジ日時 2024-05-01 21:17:14
合計ジャッジ時間 3,827 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 33 ms
10,752 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 38 ms
12,544 KB
testcase_05 RE -
testcase_06 AC 33 ms
10,752 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 39 ms
12,800 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 508 ms
12,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split(" "))

array = [[False]*N for i in range(N)]
flag = {}

for i in range(M):
	Sa,Sb = map(int,input().split(" "))
	array[Sa][Sb] = True
	array[Sb][Sa] = True
	flag[Sa] = 0
	flag[Sb] = 0

#まず連結グラフか判定
def dfs(vertex):
	global flag
	global N
	global array

	if (flag[vertex] == 1):
		return 0

	flag[vertex] = 1

	for i in range(N):
		if array[vertex][i]: #頂点vertexからiへの辺が存在
			dfs(i)

dfs(Sa)

for val in flag.values():
	if val == 0:
		print("NO")
		exit(0)

#--------ここまでくれば連結グラフであることが保証hoshou#
#オイラーグラフになっているか判断#

for i in range(N):
	num = array[i].count(True)
	if num%2 == 1:
		end += 1
		if end >= 3:
			print("NO")
			exit(0)

print("YES")
0