結果

問題 No.92 逃走経路
コンテスト
ユーザー yuppe19 😺
提出日時 2015-06-16 20:50:11
言語 Python2
(2.7.18)
結果
AC  
実行時間 181 ms / 5,000 ms
コード長 433 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 64 ms
コンパイル使用メモリ 7,848 KB
最終ジャッジ日時 2025-12-03 15:38:13
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#!/usr/bin/python
from collections import defaultdict

n, m, k = map(int, raw_input().split())
G = defaultdict(list)
for _ in xrange(m):
    a, b, c = map(int, raw_input().split())
    G[c].append((a-1, b-1))
    G[c].append((b-1, a-1))
d = map(int, raw_input().split())
arr = set(xrange(n))
for x in d:
    arr = {to for fra, to in G[x] if fra in arr}
res = list(map(lambda e: e+1, arr))
print len(res)
print ' '.join(map(str, res))
0