結果

問題 No.92 逃走経路
ユーザー DialBirdDialBird
提出日時 2017-03-18 17:52:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 536 ms / 5,000 ms
コード長 535 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,748 KB
実行使用メモリ 8,368 KB
最終ジャッジ日時 2023-09-18 02:29:28
合計ジャッジ時間 4,326 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 146 ms
8,368 KB
testcase_01 AC 16 ms
7,772 KB
testcase_02 AC 15 ms
7,808 KB
testcase_03 AC 15 ms
7,824 KB
testcase_04 AC 15 ms
7,844 KB
testcase_05 AC 514 ms
7,828 KB
testcase_06 AC 129 ms
8,196 KB
testcase_07 AC 126 ms
8,204 KB
testcase_08 AC 17 ms
7,772 KB
testcase_09 AC 40 ms
7,932 KB
testcase_10 AC 536 ms
7,928 KB
testcase_11 AC 441 ms
7,804 KB
testcase_12 AC 490 ms
8,172 KB
testcase_13 AC 32 ms
8,304 KB
testcase_14 AC 50 ms
8,304 KB
testcase_15 AC 72 ms
8,276 KB
testcase_16 AC 90 ms
8,268 KB
testcase_17 AC 138 ms
8,348 KB
testcase_18 AC 134 ms
8,240 KB
testcase_19 AC 122 ms
8,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,K = [int(i) for i in input().split()]
a = [0]*M
b = [0]*M
c = [0]*M

for i in range(M):
    a[i],b[i],c[i] = map(int, input().split())

candidates = set(range(1,N+1))
for k in map(int, input().split()):
    new_candidates = set([])
    for i in range(M):
        if c[i] == k:
            if a[i] in candidates:
                new_candidates.add(b[i])
            if b[i] in candidates:
                new_candidates.add(a[i])
    candidates = new_candidates


print(len(candidates))
print(" ".join([str(i) for i in candidates]))
0