結果

問題 No.92 逃走経路
ユーザー gorugo30
提出日時 2021-02-26 20:37:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,802 ms / 5,000 ms
コード長 549 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 82,340 KB
実行使用メモリ 76,172 KB
最終ジャッジ日時 2024-10-02 13:07:24
合計ジャッジ時間 10,193 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, K = map(int, input().split())
adj = [[] for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    adj[a].append((b, c))
    adj[b].append((a, c))
D = list(map(int, input().split()))[::-1]
ans = []
for end in range(N):
    prev = set([end])
    for i in range(K):
        nex = set()
        for p in prev:
            for nv, c in adj[p]:
                if c == D[i]:
                    nex.add(nv)
        prev = nex
    if len(prev) > 0:
        ans.append(end + 1)
print(len(ans))
print(*ans)
0