結果

問題 No.92 逃走経路
ユーザー akanayaakanaya
提出日時 2020-03-28 15:13:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 740 bytes
コンパイル時間 1,009 ms
コンパイル使用メモリ 10,772 KB
実行使用メモリ 8,904 KB
最終ジャッジ日時 2023-08-30 17:45:23
合計ジャッジ時間 2,614 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 15 ms
7,772 KB
testcase_02 AC 15 ms
7,780 KB
testcase_03 AC 16 ms
7,800 KB
testcase_04 AC 16 ms
7,924 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m ,k = list(map(int, input().split(' ')))
abcm = [None] * m
for i in range(m):
    abcm[i] = list(map(int, input().split(' ')))

dk = list(map(int, input().split(' ')))


def solver(cp, x):
    if x == k:
        return cp

    for i in range(m):
        bg = abcm[i]

        if bg[0] == cp and bg[2] == dk[x]:
            r = solver(bg[1], x + 1)
            return r
            
        if bg[1] == cp and bg[2] == dk[x]:
            r = solver(bg[0],  x + 1)
            return r
 
    return None

c = 0
cps = set()
for i in range(1, n + 1):
    result = solver(i, 0)

    if result is not None:
        c += 1
        cps.add(result)
        
cps = sorted(cps)
print(c)
for i in range(c):
    print(cps[i] ,end=' ')
print()

    
0