結果

問題 No.92 逃走経路
ユーザー ytftytft
提出日時 2022-11-10 09:18:37
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 272 ms / 5,000 ms
コード長 460 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 90,168 KB
最終ジャッジ日時 2023-09-30 18:42:02
合計ジャッジ時間 5,396 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 272 ms
90,168 KB
testcase_01 AC 130 ms
29,604 KB
testcase_02 AC 130 ms
29,508 KB
testcase_03 AC 134 ms
29,532 KB
testcase_04 AC 137 ms
29,644 KB
testcase_05 AC 142 ms
29,536 KB
testcase_06 AC 141 ms
29,844 KB
testcase_07 AC 141 ms
29,924 KB
testcase_08 AC 221 ms
29,584 KB
testcase_09 AC 222 ms
29,624 KB
testcase_10 AC 176 ms
29,680 KB
testcase_11 AC 188 ms
29,624 KB
testcase_12 AC 229 ms
29,656 KB
testcase_13 AC 223 ms
29,676 KB
testcase_14 AC 224 ms
29,808 KB
testcase_15 AC 218 ms
29,928 KB
testcase_16 AC 223 ms
30,088 KB
testcase_17 AC 223 ms
30,536 KB
testcase_18 AC 177 ms
30,228 KB
testcase_19 AC 157 ms
29,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np
input=lambda:sys.stdin.readline().rstrip()
N,M,K=map(int,input().split())
mat={}
for i in range(M):
	a,b,c=map(int,input().split())
	if not c in mat:
		mat[c]=np.zeros((N,N))
	mat[c][a-1][b-1]=1
	mat[c][b-1][a-1]=1
D=list(map(int,input().split()))
pot=np.ones((N,1))
for i in D:
	pot=mat[i]@pot
	for i in range(N):
		pot[i][0]=min(1,pot[i][0])
ans=[]
for i in range(N):
	if pot[i][0]:
		ans.append(i+1)
print(len(ans))
print(*ans)
0