結果

問題 No.807 umg tours
ユーザー buey_tbuey_t
提出日時 2023-03-19 13:13:12
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,844 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 184,804 KB
最終ジャッジ日時 2023-10-18 17:46:14
合計ジャッジ時間 49,858 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 164 ms
89,068 KB
testcase_01 AC 170 ms
89,240 KB
testcase_02 AC 184 ms
89,272 KB
testcase_03 AC 181 ms
89,272 KB
testcase_04 AC 166 ms
89,072 KB
testcase_05 AC 170 ms
89,236 KB
testcase_06 AC 189 ms
89,780 KB
testcase_07 AC 180 ms
89,268 KB
testcase_08 AC 147 ms
88,396 KB
testcase_09 AC 156 ms
88,956 KB
testcase_10 AC 159 ms
88,980 KB
testcase_11 AC 3,906 ms
156,540 KB
testcase_12 AC 2,497 ms
139,660 KB
testcase_13 AC 3,821 ms
158,636 KB
testcase_14 AC 1,541 ms
119,596 KB
testcase_15 AC 1,177 ms
112,064 KB
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 1,712 ms
128,972 KB
testcase_21 AC 1,838 ms
130,620 KB
testcase_22 AC 830 ms
107,216 KB
testcase_23 AC 676 ms
102,764 KB
testcase_24 AC 2,167 ms
174,760 KB
testcase_25 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    try:
        import pypyjit
        pypyjit.set_param('max_unroll_recursion=-1')
    except:
        pass
    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)]
    
    while len(Q) > 0:
        cnt,pos,f = heappop(Q)
        
        if dis[pos][f] != INF:
            continue
        
        dis[pos][f] = cnt
        
        for nx,d in G[pos]:
            if dis[nx][f] == INF:
                heappush(Q,(cnt+d,nx,f))
                if f == 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()
0