結果

問題 No.92 逃走経路
ユーザー pessimist
提出日時 2025-06-19 21:19:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 64 ms / 5,000 ms
コード長 410 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 82,312 KB
実行使用メモリ 66,864 KB
最終ジャッジ日時 2025-06-19 21:19:15
合計ジャッジ時間 2,512 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline

N,M,K=map(int,readline().split())
ABC=tuple(tuple(map(int,readline().split())) for _ in range(M))
D=tuple(map(int,read().split()))

p=[True]*(N+1)
for d in D:
  q=[False]*(N+1)
  for a,b,c in ABC:
    if c!=d: continue
    if p[a]: q[b]=True
    if p[b]: q[a]=True
  p=q
ans=[i for i, x in enumerate(p) if x]
print(len(ans))
print(*ans)
0