結果

問題 No.1473 おでぶなおばけさん
ユーザー buey_t
提出日時 2023-03-26 10:11:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,705 bytes
コンパイル時間 1,819 ms
コンパイル使用メモリ 82,000 KB
実行使用メモリ 108,116 KB
最終ジャッジ日時 2024-09-19 09:30:38
合計ジャッジ時間 22,635 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 38 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    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
    #再帰ならPython!!!!!!!!!!!!!!!!!!!!!!!!!!
    
    
    '''
    
    
    
    '''
    
    N,M = map(int, input().split())
    
    G = [[] for _ in range(N+1)]
    
    for _ in range(M):
        u,v,w = map(int, input().split())
        G[u].append((v,w))
        G[v].append((u,w))
    
    Q = []
    heappush(Q,(-(INF*(N+1)+N),1))
    
    seen = [0]*(N+1)
    while len(Q) > 0:
        tmp,pos = heappop(Q)
        tmp = -tmp
        mx = tmp//(N+1)
        cnt = tmp%(N+1)-N
        cnt = -cnt
        
        if seen[pos] != 0:
            continue
        seen[pos] = 1
        
        if pos == N:
            print(mx,cnt)
            exit()
        
        for nx,w in G[pos]:
            if seen[nx] == 0:
                heappush(Q,(-(min(mx,w)*(N+1)+N-(cnt+1)),nx))
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0