結果

問題 No.92 逃走経路
ユーザー tookunn_1213tookunn_1213
提出日時 2017-05-05 12:43:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 421 ms / 5,000 ms
コード長 564 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 10,936 KB
実行使用メモリ 9,496 KB
最終ジャッジ日時 2023-10-12 09:47:03
合計ジャッジ時間 3,602 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
9,496 KB
testcase_01 AC 16 ms
7,912 KB
testcase_02 AC 16 ms
7,864 KB
testcase_03 AC 16 ms
7,796 KB
testcase_04 AC 16 ms
7,856 KB
testcase_05 AC 412 ms
8,580 KB
testcase_06 AC 93 ms
8,620 KB
testcase_07 AC 92 ms
8,736 KB
testcase_08 AC 22 ms
9,352 KB
testcase_09 AC 56 ms
9,236 KB
testcase_10 AC 417 ms
9,040 KB
testcase_11 AC 381 ms
9,020 KB
testcase_12 AC 421 ms
9,392 KB
testcase_13 AC 42 ms
9,272 KB
testcase_14 AC 47 ms
9,416 KB
testcase_15 AC 64 ms
9,364 KB
testcase_16 AC 57 ms
9,340 KB
testcase_17 AC 78 ms
9,440 KB
testcase_18 AC 75 ms
8,996 KB
testcase_19 AC 71 ms
8,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(1000000)
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:
		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