結果

問題 No.807 umg tours
ユーザー DrDrpilotDrDrpilot
提出日時 2022-06-24 16:29:02
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 718 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 82,336 KB
実行使用メモリ 177,748 KB
最終ジャッジ日時 2024-04-25 22:42:26
合計ジャッジ時間 37,243 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
66,420 KB
testcase_01 AC 60 ms
66,272 KB
testcase_02 AC 91 ms
76,932 KB
testcase_03 AC 80 ms
73,104 KB
testcase_04 AC 58 ms
64,728 KB
testcase_05 AC 64 ms
68,428 KB
testcase_06 AC 84 ms
74,208 KB
testcase_07 AC 76 ms
72,512 KB
testcase_08 AC 41 ms
54,256 KB
testcase_09 AC 46 ms
60,540 KB
testcase_10 AC 47 ms
60,072 KB
testcase_11 AC 2,879 ms
148,336 KB
testcase_12 AC 2,149 ms
134,360 KB
testcase_13 AC 2,998 ms
152,692 KB
testcase_14 AC 1,268 ms
110,680 KB
testcase_15 AC 873 ms
101,264 KB
testcase_16 AC 3,106 ms
154,532 KB
testcase_17 AC 3,931 ms
174,100 KB
testcase_18 AC 3,729 ms
172,628 KB
testcase_19 AC 3,504 ms
166,864 KB
testcase_20 AC 1,235 ms
122,600 KB
testcase_21 AC 1,301 ms
125,324 KB
testcase_22 AC 595 ms
96,956 KB
testcase_23 AC 506 ms
92,024 KB
testcase_24 AC 1,294 ms
153,844 KB
testcase_25 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
n,m=map(int,input().split())
g=[[] for _ in range(n)]
for _ in range(m):
    a,b,c=map(int,input().split())
    g[a-1].append((b-1,c))
    g[b-1].append((a-1,c))
q=[(0,0,0)]
visited=[[False]*2 for _ in range(n)]
visited[0][1]=True
dst=[[10**18]*2 for _ in range(n)]
dst[0][1]=0
while q:
    now_d,f,now_place=heapq.heappop(q)
    if visited[now_place][f]:
        continue
    dst[now_place][f]=now_d
    visited[now_place][f]=True
    for to_place,cost in g[now_place]:
        if visited[to_place][f]==False:
            heapq.heappush(q,(now_d+cost,f,to_place))
        if not f and visited[to_place][1]==False:
            heapq.heappush(q,(now_d,1,to_place))
for i in range(n):
    print(sum(dst[i]))
0