結果

問題 No.92 逃走経路
ユーザー yaoshimax
提出日時 2015-03-02 01:19:46
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 555 bytes
コンパイル時間 457 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 33,152 KB
最終ジャッジ日時 2024-06-24 00:55:05
合計ジャッジ時間 12,848 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10 RE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,K=map(int,raw_input().split())
edge=[[]for i in range(N)]
for i in range(M):
    a,b,c = map(int,raw_input().split())
    edge[a-1].append((b-1,c))
    edge[b-1].append((a-1,c))
d=map(int,raw_input().split())
d.reverse()
ans = []

def dfs(cur,depth):
    if depth==K:
        return True
    for i in range(len(edge[cur])):
        nxt,cost = edge[cur][i]
        if cost == d[depth] and dfs(nxt,depth+1):
            return True
    return False

for i in range(N):
    if dfs(i,0):
        ans.append(i)
print len(ans)
for a in ans:
    print a+1,

0