結果

問題 No.92 逃走経路
ユーザー rlangevinrlangevin
提出日時 2023-01-16 12:38:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 5,000 ms
コード長 575 bytes
コンパイル時間 467 ms
コンパイル使用メモリ 82,464 KB
実行使用メモリ 72,612 KB
最終ジャッジ日時 2024-06-09 19:25:01
合計ジャッジ時間 2,486 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
72,612 KB
testcase_01 AC 36 ms
52,688 KB
testcase_02 AC 36 ms
53,792 KB
testcase_03 AC 37 ms
52,936 KB
testcase_04 AC 38 ms
53,136 KB
testcase_05 AC 74 ms
67,908 KB
testcase_06 AC 68 ms
68,092 KB
testcase_07 AC 67 ms
67,780 KB
testcase_08 AC 46 ms
63,024 KB
testcase_09 AC 49 ms
63,632 KB
testcase_10 AC 73 ms
68,576 KB
testcase_11 AC 73 ms
69,944 KB
testcase_12 AC 78 ms
70,304 KB
testcase_13 AC 53 ms
67,040 KB
testcase_14 AC 54 ms
66,040 KB
testcase_15 AC 67 ms
68,588 KB
testcase_16 AC 67 ms
69,652 KB
testcase_17 AC 74 ms
70,756 KB
testcase_18 AC 75 ms
71,784 KB
testcase_19 AC 77 ms
71,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, K = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    a, b = a - 1 , b - 1
    G[a].append((b, c))
    G[b].append((a, c))

D = list(map(int, input().split()))

pre = [1] * N
for i in range(K):
    dp = [0] * N
    for s in range(N):
        if not pre[s]:
            continue
        for u, c in G[s]:
            if c != D[i]:
                continue
            dp[u] |= pre[s]
    dp, pre = pre, dp

ans = []
for i in range(N):
    if pre[i]:
        ans.append(i + 1)

print(len(ans))
print(*ans)
0