結果

問題 No.92 逃走経路
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-01-14 17:40:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 125 ms / 5,000 ms
コード長 800 bytes
コンパイル時間 1,127 ms
コンパイル使用メモリ 87,132 KB
実行使用メモリ 78,180 KB
最終ジャッジ日時 2023-08-26 23:16:31
合計ジャッジ時間 4,506 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
77,844 KB
testcase_01 AC 97 ms
72,920 KB
testcase_02 AC 92 ms
72,724 KB
testcase_03 AC 96 ms
72,772 KB
testcase_04 AC 94 ms
72,776 KB
testcase_05 AC 115 ms
77,824 KB
testcase_06 AC 107 ms
77,788 KB
testcase_07 AC 111 ms
78,160 KB
testcase_08 AC 102 ms
77,928 KB
testcase_09 AC 108 ms
78,168 KB
testcase_10 AC 121 ms
78,008 KB
testcase_11 AC 120 ms
77,988 KB
testcase_12 AC 120 ms
78,052 KB
testcase_13 AC 109 ms
78,108 KB
testcase_14 AC 111 ms
78,180 KB
testcase_15 AC 116 ms
77,876 KB
testcase_16 AC 125 ms
78,128 KB
testcase_17 AC 123 ms
77,908 KB
testcase_18 AC 116 ms
77,980 KB
testcase_19 AC 115 ms
78,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from heapq import *
from functools import *
import sys,math
input = sys.stdin.readline

N,M,K = map(int,input().split())
e = [[] for _ in range(N)]
for _ in range(M):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    e[a].append((b,c))
    e[b].append((a,c))
D = list(map(int,input().split()))

cnt = [[False]*(K+1) for _ in range(N)]
for i in range(N):
    cnt[i][0]=True

for i in range(K):
    
    d = D[i]
    
    for j in range(N):
        
        if cnt[j][i]:
            
            for ix,ic in e[j]:
                
                if ic==d:
                    
                    cnt[ix][i+1] = True
                    
ans = []
for i in range(N):
    if cnt[i][-1]:
        ans.append(i+1)
print(len(ans))
print(*ans)
0