結果

問題 No.92 逃走経路
ユーザー hiyokko2hiyokko2
提出日時 2016-07-29 22:01:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 518 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-04-24 12:21:56
合計ジャッジ時間 2,620 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

def check(i_, v_):
	if i_ == K:
		ans.append(v_)
		return True
	for (v, c) in G[v_]:
		if c == d[i_]:
			if check(i_ + 1, v):
				return True
	return False

N, M, K = map(int, input().split())
G = [[] for _ in range(N + 1)]
for _ in range(M):
	a, b, c = map(int, input().split())
	G[a].append((b, c))
	G[b].append((a, c))

d = list(map(int, input().split()))
"""
print("d=")
print(d)
print("G=")
print(G)
"""

ans = []
for i in range(1, N + 1):
	check(0, i)
		
print(len(ans))
ans.sort()
print(' '.join(map(str, ans)))
0