結果

問題 No.92 逃走経路
ユーザー tookunn_1213
提出日時 2017-05-05 12:32:09
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 535 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 12,032 KB
最終ジャッジ日時 2024-09-14 08:40:54
合計ジャッジ時間 2,210 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10 RE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,K = map(int,input().split())
graph = [[] for i in range(N)]
for i in range(M):
	a,b,c = map(int,input().split())
	graph[a-1].append((b-1,c))
	graph[b-1].append((a-1,c))
d = [int(i) for i in input().split()]
used = [[False for j in range(K)]for i in range(N)]
ans = set([])
def dfs(n,c):
	if c == K:
		global ans
		ans.add(n+1)
		return
	if used[n][c]:
		return
	used[n][c] = True
	for e in graph[n]:
		if e[1] == d[c]:
			dfs(e[0],c+1)
for i in range(N):
	dfs(i,0)
print(len(ans))
print(' '.join(str(i) for i in sorted(list(ans))))
0