結果
問題 | No.788 トラックの移動 |
ユーザー | nephrologist |
提出日時 | 2020-02-26 22:11:25 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,391 bytes |
コンパイル時間 | 389 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 115,948 KB |
最終ジャッジ日時 | 2024-04-21 16:35:58 |
合計ジャッジ時間 | 14,508 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | AC | 45 ms
53,120 KB |
testcase_02 | AC | 44 ms
52,884 KB |
testcase_03 | AC | 43 ms
53,376 KB |
testcase_04 | AC | 676 ms
86,036 KB |
testcase_05 | TLE | - |
testcase_06 | TLE | - |
testcase_07 | AC | 45 ms
52,864 KB |
testcase_08 | AC | 46 ms
53,136 KB |
testcase_09 | AC | 45 ms
53,376 KB |
testcase_10 | AC | 45 ms
53,504 KB |
testcase_11 | AC | 46 ms
53,248 KB |
testcase_12 | AC | 46 ms
53,376 KB |
testcase_13 | AC | 43 ms
52,480 KB |
testcase_14 | AC | 43 ms
52,992 KB |
testcase_15 | AC | 612 ms
109,056 KB |
testcase_16 | TLE | - |
ソースコード
import sys input=sys.stdin.readline #dijkstra? from heapq import heappop, heappush, heapify n,m,l=map(int,input().split()) T=list(map(int,input().split())) graph=[[] for _ in range(n+1)] dist=[[10**10]*(n+1) for _ in range(n+1)] if T.count(0)==n-1: print(0) else: for _ in range(m): a,b,c=map(int,input().split()) graph[a].append((c,b)) graph[b].append((c,a)) def dij(s,graph,dist): used=[False]*(n+1) used[s]=True dist[s][s]=0 edgelist=[] for es in graph[s]: heappush(edgelist,es) while edgelist: kyori,ten=heappop(edgelist) if used[ten]==True: continue dist[s][ten]=kyori used[ten]=True for es in graph[ten]: if used[es[1]]==False: heappush(edgelist,(es[0]+dist[s][ten], es[1])) return dist ans=10**20 for i in range(1,n+1): dist=dij(i, graph,dist) for p in range(1,n+1): ouhuku=0 for j in range(n): ouhuku+=2*T[j]*dist[p][j+1] for first in range(1,n+1): if T[first-1]==0: continue if first==p: temp=ouhuku+dist[l][first] else: temp=ouhuku+dist[l][first]+dist[first][p]-(dist[p][first]*2) ans=min(ans,temp) print(ans)