結果

問題 No.92 逃走経路
ユーザー tnodinotnodino
提出日時 2022-03-01 05:52:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 422 ms / 5,000 ms
コード長 586 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 8,980 KB
最終ジャッジ日時 2023-09-21 14:54:31
合計ジャッジ時間 4,671 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 172 ms
8,980 KB
testcase_01 AC 19 ms
8,536 KB
testcase_02 AC 18 ms
8,536 KB
testcase_03 AC 19 ms
8,596 KB
testcase_04 AC 18 ms
8,548 KB
testcase_05 AC 422 ms
8,752 KB
testcase_06 AC 267 ms
8,840 KB
testcase_07 AC 266 ms
8,856 KB
testcase_08 AC 20 ms
8,516 KB
testcase_09 AC 53 ms
8,632 KB
testcase_10 AC 386 ms
8,812 KB
testcase_11 AC 345 ms
8,684 KB
testcase_12 AC 404 ms
8,696 KB
testcase_13 AC 39 ms
8,624 KB
testcase_14 AC 53 ms
8,784 KB
testcase_15 AC 91 ms
8,748 KB
testcase_16 AC 97 ms
8,764 KB
testcase_17 AC 155 ms
8,732 KB
testcase_18 AC 181 ms
8,920 KB
testcase_19 AC 182 ms
8,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)])
0