結果

問題 No.583 鉄道同好会
ユーザー KoshStormKoshStorm
提出日時 2017-10-28 12:06:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 656 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 13,184 KB
最終ジャッジ日時 2024-05-01 20:38:32
合計ジャッジ時間 2,954 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,624 KB
testcase_01 AC 26 ms
10,624 KB
testcase_02 AC 25 ms
10,752 KB
testcase_03 AC 26 ms
10,752 KB
testcase_04 AC 35 ms
12,544 KB
testcase_05 AC 26 ms
10,752 KB
testcase_06 AC 26 ms
10,752 KB
testcase_07 AC 27 ms
10,752 KB
testcase_08 AC 27 ms
10,752 KB
testcase_09 AC 26 ms
10,752 KB
testcase_10 AC 31 ms
12,544 KB
testcase_11 AC 114 ms
12,800 KB
testcase_12 AC 153 ms
12,672 KB
testcase_13 AC 149 ms
12,800 KB
testcase_14 AC 149 ms
12,800 KB
testcase_15 AC 179 ms
12,672 KB
testcase_16 AC 323 ms
12,800 KB
testcase_17 AC 392 ms
12,672 KB
testcase_18 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#C問題:鉄道同好会


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


array = [[False]*N for i in range(N)]
end = 0
count = 0

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

end_i = Sa

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

def search (i,j):
	global array
	global count

	count += 1	

	if count == M:
		print("YES")
		exit(0)

	array[i][j] = False
	array[j][i] = False

	for k in range(N):
		if array[j][k] == True:
			search(j,k)

for i in range(N):
	if (array[end_i][i] == True):
		search(end_i,i)
		break
print("NO")
0