結果
問題 | No.92 逃走経路 |
ユーザー |
![]() |
提出日時 | 2016-04-29 20:38:45 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 397 ms / 5,000 ms |
コード長 | 990 bytes |
コンパイル時間 | 108 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 19,200 KB |
最終ジャッジ日時 | 2024-10-04 17:52:52 |
合計ジャッジ時間 | 2,850 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#!/usr/bin/env python3import arrayimport collectionsEdge = collections.namedtuple("Edge", "source dest")def possible_current_vertices(n, cost_to_edges, ds):possible_vertices = []possible_vertices.append(set(range(1, n + 1)))for index, d in enumerate(ds, start=1):possible_vertices.append(set())for edge in cost_to_edges[d]:if edge.source in possible_vertices[index - 1]:possible_vertices[index].add(edge.dest)return possible_vertices[-1]def main():n, m, k = map(int, input().split())cost_to_edges = collections.defaultdict(set)for _ in range(m):a, b, c = map(int, input().split())cost_to_edges[c].add(Edge(a, b))cost_to_edges[c].add(Edge(b, a))ds = array.array("L", map(int, input().split()))answer = possible_current_vertices(n, cost_to_edges, ds)print(len(answer))print(" ".join(map(str, sorted(answer))))if __name__ == '__main__':main()