結果
問題 | No.92 逃走経路 |
ユーザー |
![]() |
提出日時 | 2017-05-05 12:43:15 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 491 ms / 5,000 ms |
コード長 | 564 bytes |
コンパイル時間 | 191 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,904 KB |
最終ジャッジ日時 | 2024-09-14 08:41:12 |
合計ジャッジ時間 | 3,895 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
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))))