結果
| 問題 | No.92 逃走経路 |
| コンテスト | |
| ユーザー |
nbisco
|
| 提出日時 | 2017-01-11 23:59:33 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 386 ms / 5,000 ms |
| コード長 | 664 bytes |
| 記録 | |
| コンパイル時間 | 203 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-12-21 09:56:44 |
| 合計ジャッジ時間 | 3,529 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
N, M, K = [int(i) for i in input().strip().split(" ")]
fee = {}
for i in range(M):
a, b, c = [int(i) for i in input().strip().split(" ")]
if fee.get(c):
fee[c].append((a,b))
else:
fee[c] = [(a,b)]
D = [int(i) for i in input().strip().split(" ")]
cur = set([])
towns = fee[D[0]]
for town in towns:
cur.add(town[0])
cur.add(town[1])
next = set([])
for d in D[1:]:
towns = fee[d]
for town in towns:
if town[0] in cur:
next.add(town[1])
if town[1] in cur:
next.add(town[0])
cur = next
next = set([])
cur = list(cur)
print(len(cur))
print(" ".join([str(i) for i in cur]))
nbisco