結果

問題 No.92 逃走経路
ユーザー kutsutamakutsutama
提出日時 2019-01-07 13:39:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 580 ms / 5,000 ms
コード長 650 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 9,196 KB
最終ジャッジ日時 2023-08-15 16:30:50
合計ジャッジ時間 4,852 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 162 ms
9,196 KB
testcase_01 AC 14 ms
7,828 KB
testcase_02 AC 12 ms
7,844 KB
testcase_03 AC 13 ms
7,848 KB
testcase_04 AC 12 ms
7,816 KB
testcase_05 AC 580 ms
8,220 KB
testcase_06 AC 128 ms
8,220 KB
testcase_07 AC 129 ms
8,232 KB
testcase_08 AC 17 ms
9,028 KB
testcase_09 AC 42 ms
9,032 KB
testcase_10 AC 571 ms
8,720 KB
testcase_11 AC 553 ms
8,760 KB
testcase_12 AC 561 ms
9,008 KB
testcase_13 AC 34 ms
9,004 KB
testcase_14 AC 51 ms
9,028 KB
testcase_15 AC 81 ms
9,064 KB
testcase_16 AC 95 ms
9,044 KB
testcase_17 AC 145 ms
9,004 KB
testcase_18 AC 139 ms
8,756 KB
testcase_19 AC 141 ms
8,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, K = [int(x) for x in input().split()]
a = [0] * M
b = [0] * M
c = [0] * M
for i in range(M):
    a[i], b[i], c[i] = [int(x) for x in input().split()]
d = [int(x) for x in input().split()]

pos = [[False] * (N + 1) for _ in range(K + 1)]
for i in range(1, len(pos[0])):
    pos[0][i] = True

for kk in range(K):
    for mm in range(M):
        if c[mm] == d[kk]:
            if pos[kk][a[mm]]:
                pos[kk + 1][b[mm]] = True
            if pos[kk][b[mm]]:
                pos[kk + 1][a[mm]] = True

cnt = pos[K].count(True)
lis = []
for nn, ok in enumerate(pos[K]):
    if ok:
        lis += [str(nn)]
print(cnt)
print(' '.join(lis))
0