結果
| 問題 | 
                            No.92 逃走経路
                             | 
                    
| コンテスト | |
| ユーザー | 
                            👑  Kazun
                         | 
                    
| 提出日時 | 2021-02-07 19:36:21 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 114 ms / 5,000 ms | 
| コード長 | 385 bytes | 
| コンパイル時間 | 264 ms | 
| コンパイル使用メモリ | 82,444 KB | 
| 実行使用メモリ | 76,032 KB | 
| 最終ジャッジ日時 | 2024-07-04 12:34:49 | 
| 合計ジャッジ時間 | 2,725 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 18 | 
ソースコード
from collections import defaultdict
N,M,K=map(int,input().split())
E=defaultdict(list)
for _ in range(M):
    a,b,c=map(int,input().split())
    E[c].append((a,b))
D=map(int,input().split())
S=set(range(1,N+1))
for d in D:
    T=set()
    for u,v in E[d]:
        if u in S:
            T.add(v)
        if v in S:
            T.add(u)
    S=T.copy()
print(len(S))
print(*sorted(S))
            
            
            
        
            
Kazun