結果

問題 No.92 逃走経路
ユーザー rlangevinrlangevin
提出日時 2023-01-16 12:38:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 106 ms / 5,000 ms
コード長 575 bytes
コンパイル時間 975 ms
コンパイル使用メモリ 87,340 KB
実行使用メモリ 76,948 KB
最終ジャッジ日時 2023-08-29 01:03:20
合計ジャッジ時間 3,911 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
76,896 KB
testcase_01 AC 68 ms
71,304 KB
testcase_02 AC 70 ms
71,572 KB
testcase_03 AC 69 ms
71,292 KB
testcase_04 AC 66 ms
71,400 KB
testcase_05 AC 101 ms
76,716 KB
testcase_06 AC 96 ms
76,556 KB
testcase_07 AC 99 ms
76,824 KB
testcase_08 AC 75 ms
76,652 KB
testcase_09 AC 81 ms
76,536 KB
testcase_10 AC 104 ms
76,584 KB
testcase_11 AC 99 ms
76,888 KB
testcase_12 AC 106 ms
76,948 KB
testcase_13 AC 81 ms
76,656 KB
testcase_14 AC 86 ms
76,700 KB
testcase_15 AC 100 ms
76,844 KB
testcase_16 AC 99 ms
76,864 KB
testcase_17 AC 103 ms
76,872 KB
testcase_18 AC 103 ms
76,900 KB
testcase_19 AC 105 ms
76,820 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