結果

問題 No.92 逃走経路
ユーザー gorugo30gorugo30
提出日時 2021-02-26 20:37:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,707 ms / 5,000 ms
コード長 549 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 82,324 KB
実行使用メモリ 76,392 KB
最終ジャッジ日時 2024-04-10 11:08:25
合計ジャッジ時間 9,322 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 553 ms
76,208 KB
testcase_01 AC 34 ms
53,756 KB
testcase_02 AC 33 ms
52,660 KB
testcase_03 AC 33 ms
52,660 KB
testcase_04 AC 33 ms
53,004 KB
testcase_05 AC 84 ms
69,156 KB
testcase_06 AC 63 ms
67,716 KB
testcase_07 AC 62 ms
68,840 KB
testcase_08 AC 40 ms
65,420 KB
testcase_09 AC 49 ms
75,508 KB
testcase_10 AC 1,436 ms
76,088 KB
testcase_11 AC 922 ms
76,220 KB
testcase_12 AC 1,707 ms
76,392 KB
testcase_13 AC 61 ms
75,812 KB
testcase_14 AC 366 ms
75,884 KB
testcase_15 AC 541 ms
75,612 KB
testcase_16 AC 431 ms
76,072 KB
testcase_17 AC 806 ms
76,288 KB
testcase_18 AC 460 ms
76,056 KB
testcase_19 AC 121 ms
75,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, K = map(int, input().split())
adj = [[] for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    adj[a].append((b, c))
    adj[b].append((a, c))
D = list(map(int, input().split()))[::-1]
ans = []
for end in range(N):
    prev = set([end])
    for i in range(K):
        nex = set()
        for p in prev:
            for nv, c in adj[p]:
                if c == D[i]:
                    nex.add(nv)
        prev = nex
    if len(prev) > 0:
        ans.append(end + 1)
print(len(ans))
print(*ans)
0