結果
問題 | No.160 最短経路のうち辞書順最小 |
ユーザー | roiti46 |
提出日時 | 2015-03-01 23:46:16 |
言語 | PyPy2 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 831 bytes |
コンパイル時間 | 524 ms |
コンパイル使用メモリ | 77,380 KB |
実行使用メモリ | 80,368 KB |
最終ジャッジ日時 | 2023-09-06 06:02:19 |
合計ジャッジ時間 | 9,572 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 80 ms
76,188 KB |
testcase_01 | AC | 78 ms
76,480 KB |
testcase_02 | AC | 79 ms
75,980 KB |
testcase_03 | AC | 79 ms
76,420 KB |
testcase_04 | AC | 135 ms
80,276 KB |
testcase_05 | AC | 128 ms
80,196 KB |
testcase_06 | AC | 124 ms
80,368 KB |
testcase_07 | TLE | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
ソースコード
inf = 10**9 def dijkstra(s): used = [False]*N d = [inf]*N d[s] = 0 while 1: v = -1 for u in xrange(N): if not used[u] and (v == -1 or d[u] < d[v]): v = u if v == -1: break used[v] = True for u in xrange(N): d[u] = min(d[u], d[v]+cost[v][u]) return d[G] def dfs(path,t): if path[-1] == G: return path spath = set(path) res = [] for i in xrange(N): if i not in spath and t+cost[i][path[-1]] <= time: res = dfs(path+[i],t+cost[i][path[-1]]) if res: return res return [] N,M,S,G = map(int,raw_input().split()) cost = [[inf]*N for i in xrange(N)] for loop in xrange(M): a,b,c = map(int,raw_input().split()) cost[a][b] = cost[b][a] = c time = dijkstra(S) print " ".join(map(str,dfs([S],0)))