結果

問題 No.92 逃走経路
ユーザー nbisconbisco
提出日時 2017-01-11 23:59:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 314 ms / 5,000 ms
コード長 664 bytes
コンパイル時間 114 ms
コンパイル使用メモリ 10,824 KB
実行使用メモリ 8,544 KB
最終ジャッジ日時 2023-08-23 08:34:57
合計ジャッジ時間 2,839 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
8,492 KB
testcase_01 AC 16 ms
7,852 KB
testcase_02 AC 16 ms
7,784 KB
testcase_03 AC 16 ms
7,768 KB
testcase_04 AC 16 ms
7,752 KB
testcase_05 AC 314 ms
8,352 KB
testcase_06 AC 20 ms
8,488 KB
testcase_07 AC 21 ms
8,544 KB
testcase_08 AC 17 ms
8,116 KB
testcase_09 AC 31 ms
8,192 KB
testcase_10 AC 312 ms
8,292 KB
testcase_11 AC 275 ms
8,224 KB
testcase_12 AC 305 ms
8,292 KB
testcase_13 AC 27 ms
8,272 KB
testcase_14 AC 33 ms
8,364 KB
testcase_15 AC 38 ms
8,128 KB
testcase_16 AC 35 ms
8,512 KB
testcase_17 AC 36 ms
8,220 KB
testcase_18 AC 28 ms
8,200 KB
testcase_19 AC 24 ms
8,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, K = [int(i) for i in input().strip().split(" ")]

fee = {}
for i in range(M):
    a, b, c = [int(i) for i in input().strip().split(" ")]
    if fee.get(c):
        fee[c].append((a,b))
    else:
        fee[c] = [(a,b)]

D = [int(i) for i in input().strip().split(" ")]

cur = set([])
towns = fee[D[0]]
for town in towns:
    cur.add(town[0])
    cur.add(town[1])

next = set([])
for d in D[1:]:
    towns = fee[d]
    for town in towns:
        if town[0] in cur:
            next.add(town[1])
        if town[1] in cur:
            next.add(town[0])
    cur = next
    next = set([])

cur = list(cur)
print(len(cur))
print(" ".join([str(i) for i in cur]))
0