結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 168 ms
8,868 KB
testcase_01 AC 19 ms
8,592 KB
testcase_02 AC 18 ms
8,620 KB
testcase_03 AC 19 ms
8,544 KB
testcase_04 AC 18 ms
8,580 KB
testcase_05 AC 377 ms
8,744 KB
testcase_06 AC 263 ms
8,840 KB
testcase_07 AC 265 ms
8,872 KB
testcase_08 AC 20 ms
8,472 KB
testcase_09 AC 51 ms
8,540 KB
testcase_10 AC 399 ms
8,700 KB
testcase_11 AC 349 ms
8,648 KB
testcase_12 AC 385 ms
8,636 KB
testcase_13 AC 39 ms
8,576 KB
testcase_14 AC 52 ms
8,592 KB
testcase_15 AC 91 ms
8,608 KB
testcase_16 AC 95 ms
8,772 KB
testcase_17 AC 166 ms
8,744 KB
testcase_18 AC 178 ms
8,812 KB
testcase_19 AC 179 ms
8,888 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 = [i for i in range(N)]
for i in range(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