結果

問題 No.92 逃走経路
ユーザー matsu7874matsu7874
提出日時 2015-12-31 02:28:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 790 ms / 5,000 ms
コード長 780 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 11,880 KB
実行使用メモリ 10,352 KB
最終ジャッジ日時 2023-10-19 12:49:33
合計ジャッジ時間 8,447 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 378 ms
10,352 KB
testcase_01 AC 27 ms
10,140 KB
testcase_02 AC 28 ms
10,140 KB
testcase_03 AC 28 ms
10,140 KB
testcase_04 AC 33 ms
10,140 KB
testcase_05 AC 772 ms
10,212 KB
testcase_06 AC 671 ms
10,316 KB
testcase_07 AC 669 ms
10,308 KB
testcase_08 AC 42 ms
10,172 KB
testcase_09 AC 116 ms
10,184 KB
testcase_10 AC 746 ms
10,232 KB
testcase_11 AC 683 ms
10,216 KB
testcase_12 AC 790 ms
10,236 KB
testcase_13 AC 82 ms
10,276 KB
testcase_14 AC 109 ms
10,280 KB
testcase_15 AC 199 ms
10,300 KB
testcase_16 AC 211 ms
10,308 KB
testcase_17 AC 354 ms
10,352 KB
testcase_18 AC 405 ms
10,344 KB
testcase_19 AC 414 ms
10,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,K = map(int, input().split())
graph = [[[],[]] for i in range(N)]
for i in range(M):
    a,b,c = map(int, input().split())
    graph[a-1][0].append(b-1)
    graph[a-1][1].append(c)
    graph[b-1][0].append(a-1)
    graph[b-1][1].append(c)
d = list(map(int, input().split()))
candidate = [True for i in range(N)]
for i in range(K):
    next_candidate = [False for i in range(N)]
    for j in range(N):
        if not candidate[j]:
            continue
        for k in range(len(graph[j][0])):
            nv = graph[j][0][k]
            cost = graph[j][1][k]
            if cost == d[i]:
                next_candidate[nv] = True
    candidate = next_candidate[:]
ans = []
for i in range(N):
    if candidate[i]:
        ans.append(i+1)
ans.sort()
print(len(ans))
print(*ans)
0