結果
問題 | No.807 umg tours |
ユーザー | buey_t |
提出日時 | 2023-03-20 14:23:32 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 3,529 ms / 4,000 ms |
コード長 | 1,884 bytes |
コンパイル時間 | 302 ms |
コンパイル使用メモリ | 82,300 KB |
実行使用メモリ | 173,240 KB |
最終ジャッジ日時 | 2024-12-13 11:55:35 |
合計ジャッジ時間 | 35,191 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 147 ms
89,676 KB |
testcase_01 | AC | 142 ms
89,900 KB |
testcase_02 | AC | 168 ms
90,508 KB |
testcase_03 | AC | 162 ms
89,960 KB |
testcase_04 | AC | 145 ms
90,052 KB |
testcase_05 | AC | 149 ms
89,896 KB |
testcase_06 | AC | 174 ms
90,708 KB |
testcase_07 | AC | 162 ms
89,972 KB |
testcase_08 | AC | 128 ms
89,536 KB |
testcase_09 | AC | 133 ms
89,716 KB |
testcase_10 | AC | 135 ms
89,364 KB |
testcase_11 | AC | 2,505 ms
153,920 KB |
testcase_12 | AC | 1,858 ms
137,056 KB |
testcase_13 | AC | 2,649 ms
154,252 KB |
testcase_14 | AC | 1,082 ms
118,108 KB |
testcase_15 | AC | 763 ms
111,320 KB |
testcase_16 | AC | 2,744 ms
157,696 KB |
testcase_17 | AC | 3,241 ms
172,144 KB |
testcase_18 | AC | 3,331 ms
170,504 KB |
testcase_19 | AC | 3,202 ms
167,032 KB |
testcase_20 | AC | 1,135 ms
125,860 KB |
testcase_21 | AC | 1,288 ms
128,820 KB |
testcase_22 | AC | 603 ms
105,480 KB |
testcase_23 | AC | 495 ms
101,960 KB |
testcase_24 | AC | 1,196 ms
154,896 KB |
testcase_25 | AC | 3,529 ms
173,240 KB |
ソースコード
def main(): try: import sys sys.setrecursionlimit(10**7) except: pass from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum from heapq import heapify, heappop, heappush from bisect import bisect_left, bisect_right from copy import deepcopy import copy import random from collections import deque,Counter,defaultdict from itertools import permutations,combinations from decimal import Decimal,ROUND_HALF_UP #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP) from functools import lru_cache, reduce #@lru_cache(maxsize=None) from operator import add,sub,mul,xor,and_,or_,itemgetter INF = 10**18 mod1 = 10**9+7 mod2 = 998244353 #DecimalならPython ''' ''' N,M = map(int, input().split()) G = [[] for _ in range(N+1)] for _ in range(M): a,b,c = map(int, input().split()) G[a].append((b,c)) G[b].append((a,c)) Q = [] heappush(Q,(0,1,0)) dis = [[INF]*2 for _ in range(N+1)] dis[0][1] = 0 while len(Q) > 0: cnt,pos,f = heappop(Q) if dis[pos][f] != INF: continue dis[pos][f] = cnt if f == 1 and dis[pos][1] >= dis[pos][0]: continue for nx,d in G[pos]: if dis[nx][f] == INF and cnt<dis[nx][0]: heappush(Q,(cnt+d,nx,f)) if f == 0 and dis[nx][1] == INF and cnt<dis[nx][0]: heappush(Q,(cnt,nx,1)) for i in range(1,N+1): print(dis[i][0]+min(dis[i][0],dis[i][1])) if __name__ == '__main__': main()