結果
問題 | No.807 umg tours |
ユーザー | buey_t |
提出日時 | 2023-03-20 14:23:32 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 3,977 ms / 4,000 ms |
コード長 | 1,884 bytes |
コンパイル時間 | 426 ms |
コンパイル使用メモリ | 81,764 KB |
実行使用メモリ | 173,248 KB |
最終ジャッジ日時 | 2024-09-18 14:05:30 |
合計ジャッジ時間 | 38,644 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 158 ms
89,384 KB |
testcase_01 | AC | 157 ms
89,396 KB |
testcase_02 | AC | 176 ms
90,240 KB |
testcase_03 | AC | 173 ms
89,548 KB |
testcase_04 | AC | 155 ms
89,664 KB |
testcase_05 | AC | 163 ms
89,856 KB |
testcase_06 | AC | 185 ms
89,872 KB |
testcase_07 | AC | 175 ms
89,900 KB |
testcase_08 | AC | 142 ms
88,972 KB |
testcase_09 | AC | 146 ms
89,472 KB |
testcase_10 | AC | 151 ms
88,976 KB |
testcase_11 | AC | 2,804 ms
153,708 KB |
testcase_12 | AC | 2,053 ms
137,088 KB |
testcase_13 | AC | 2,875 ms
153,668 KB |
testcase_14 | AC | 1,318 ms
117,868 KB |
testcase_15 | AC | 937 ms
110,628 KB |
testcase_16 | AC | 3,168 ms
157,440 KB |
testcase_17 | AC | 3,742 ms
171,760 KB |
testcase_18 | AC | 3,665 ms
170,064 KB |
testcase_19 | AC | 3,564 ms
166,784 KB |
testcase_20 | AC | 1,268 ms
125,440 KB |
testcase_21 | AC | 1,367 ms
128,256 KB |
testcase_22 | AC | 679 ms
105,088 KB |
testcase_23 | AC | 535 ms
101,360 KB |
testcase_24 | AC | 1,267 ms
154,496 KB |
testcase_25 | AC | 3,977 ms
173,248 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()