結果
| 問題 | 
                            No.92 逃走経路
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tnodino
                         | 
                    
| 提出日時 | 2022-03-01 05:52:33 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 405 ms / 5,000 ms | 
| コード長 | 586 bytes | 
| コンパイル時間 | 77 ms | 
| コンパイル使用メモリ | 12,928 KB | 
| 実行使用メモリ | 11,136 KB | 
| 最終ジャッジ日時 | 2024-07-07 08:40:44 | 
| 合計ジャッジ時間 | 4,360 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 18 | 
ソースコード
from collections import defaultdict
N,M,K = map(int,input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append((b, c))
    G[b].append((a, c))
d = list(map(int,input().split()))
S = set()
for pos in range(N):
    for nxt,c in G[pos]:
        if c == d[0]:
            S.add(nxt)
S = list(S)
for i in range(1,K):
    T = set()
    for pos in S:
        for nxt,c in G[pos]:
            if c == d[i]:
                T.add(nxt)
    S = list(T)
S.sort()
N = len(S)
print(N)
print(*[S[i] + 1 for i in range(N)])
            
            
            
        
            
tnodino