結果

問題 No.92 逃走経路
ユーザー akanaya
提出日時 2020-03-28 15:13:18
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 740 bytes
コンパイル時間 1,230 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2025-01-02 11:24:02
合計ジャッジ時間 3,513 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 2 WA * 7 RE * 9
権限があれば一括ダウンロードができます

ソースコード

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