結果

問題 No.92 逃走経路
ユーザー ntudantuda
提出日時 2024-01-05 23:01:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 101 ms / 5,000 ms
コード長 592 bytes
コンパイル時間 358 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 75,916 KB
最終ジャッジ日時 2024-01-05 23:01:53
合計ジャッジ時間 2,744 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
73,328 KB
testcase_01 AC 35 ms
53,332 KB
testcase_02 AC 35 ms
53,332 KB
testcase_03 AC 36 ms
53,332 KB
testcase_04 AC 36 ms
53,332 KB
testcase_05 AC 87 ms
68,556 KB
testcase_06 AC 61 ms
68,552 KB
testcase_07 AC 61 ms
68,552 KB
testcase_08 AC 46 ms
62,248 KB
testcase_09 AC 54 ms
70,472 KB
testcase_10 AC 91 ms
72,660 KB
testcase_11 AC 89 ms
72,660 KB
testcase_12 AC 101 ms
75,764 KB
testcase_13 AC 54 ms
68,468 KB
testcase_14 AC 59 ms
68,444 KB
testcase_15 AC 76 ms
72,880 KB
testcase_16 AC 68 ms
72,592 KB
testcase_17 AC 84 ms
75,916 KB
testcase_18 AC 73 ms
72,720 KB
testcase_19 AC 66 ms
70,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, K = map(int, input().split())
ABC = [list(map(int, input().split())) for _ in range(M)]
D = list(map(int, input().split()))
E = [{} for _ in range(N + 1)]
Q = set()
for a, b, c in ABC:
    if c not in E[a]:
        E[a][c] = [b]
    else:
        E[a][c].append(b)
    if c not in E[b]:
        E[b][c] = [a]
    else:
        E[b][c].append(a)
    if c == D[0]:
        Q.add(a)
        Q.add(b)
for i in range(K):
    Q2 = set()
    for q in Q:
        if D[i] in E[q]:
            for x in E[q][D[i]]:
                Q2.add(x)
    Q = Q2
Q = sorted(list(Q))
print(len(Q))
print(*Q)
0