結果

問題 No.1473 おでぶなおばけさん
ユーザー buey_tbuey_t
提出日時 2023-03-26 10:47:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,319 bytes
コンパイル時間 934 ms
コンパイル使用メモリ 81,500 KB
実行使用メモリ 120,916 KB
最終ジャッジ日時 2023-10-19 13:28:01
合計ジャッジ時間 19,686 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
84,016 KB
testcase_01 AC 120 ms
84,016 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 745 ms
114,092 KB
testcase_23 AC 609 ms
108,996 KB
testcase_24 AC 606 ms
109,852 KB
testcase_25 AC 605 ms
111,472 KB
testcase_26 AC 410 ms
111,484 KB
testcase_27 AC 315 ms
97,580 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 604 ms
111,012 KB
testcase_37 AC 354 ms
109,148 KB
testcase_38 AC 194 ms
90,592 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
権限があれば一括ダウンロードができます

ソースコード

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)]
    w = []
    for _ in range(M):
        a,b,c = map(int, input().split())
        G[a].append((b,c))
        G[b].append((a,c))
        w.append(c)
    
    w.sort()
    
    r = M-1
    l = 0
    
    while r-l > 1:
        m = (r+l)//2
        
        Q = deque()
        Q.append((1,0))
        seen = [0]*(N+1)
        ans = -1
        while len(Q) > 0:
            pos,cnt = Q.popleft()
            
            if seen[pos] == 1:
                continue
            
            seen[pos] = 1
            
            if pos == N:
                ans = cnt
                break
            
            for nx,d in G[pos]:
                if d >= w[m] and seen[nx] == 0:
                    Q.append((nx,cnt+1))
        
        if ans == -1:
            l = m
        else:
            r = m
    
    Q = deque()
    Q.append((1,0))
    seen = [0]*(N+1)
    ans = -1
    while len(Q) > 0:
        pos,cnt = Q.popleft()
        
        if seen[pos] == 1:
            continue
        
        seen[pos] = 1
        
        if pos == N:
            ans = cnt
            break
        
        for nx,d in G[pos]:
            if d >= w[r] and seen[nx] == 0:
                Q.append((nx,cnt+1))
    
    print(w[r],ans)
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0