結果

問題 No.92 逃走経路
ユーザー roiti46roiti46
提出日時 2014-12-07 20:57:49
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 634 bytes
コンパイル時間 497 ms
コンパイル使用メモリ 6,672 KB
実行使用メモリ 8,508 KB
最終ジャッジ日時 2023-09-02 10:26:24
合計ジャッジ時間 13,046 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,836 ms
8,452 KB
testcase_01 AC 11 ms
5,952 KB
testcase_02 AC 11 ms
6,076 KB
testcase_03 AC 11 ms
5,964 KB
testcase_04 AC 11 ms
5,860 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 AC 266 ms
8,304 KB
testcase_14 AC 2,578 ms
8,448 KB
testcase_15 AC 601 ms
8,376 KB
testcase_16 AC 691 ms
8,352 KB
testcase_17 AC 1,019 ms
8,436 KB
testcase_18 AC 227 ms
7,264 KB
testcase_19 AC 98 ms
6,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(s,k):
    if k == K: return True
    res = False
    for i in range(N):
        for c in G[s][i]:
            if c == d[k]:
                res = (solve(i,k+1) or res)
                if res: break
        if res: break
    return res

N,M,K = map(int,raw_input().split())
G = [[[] for _ in range(N)] for _ in range(N)]
for roop in range(M):
    a,b,c = map(int,raw_input().split())
    G[a-1][b-1].append(c);G[b-1][a-1].append(c)
d = map(int,raw_input().split())[::-1]

start = []
for s in range(N):
    if solve(s,0):
        start.append(s+1)
print len(start)
print " ".join(map(str,sorted(start)))
0