結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
84,064 KB
testcase_01 AC 130 ms
84,060 KB
testcase_02 AC 703 ms
114,372 KB
testcase_03 AC 489 ms
110,868 KB
testcase_04 AC 418 ms
102,380 KB
testcase_05 AC 281 ms
92,980 KB
testcase_06 AC 672 ms
111,072 KB
testcase_07 AC 618 ms
114,196 KB
testcase_08 AC 784 ms
114,204 KB
testcase_09 AC 628 ms
114,984 KB
testcase_10 AC 331 ms
99,616 KB
testcase_11 AC 367 ms
100,172 KB
testcase_12 AC 306 ms
99,616 KB
testcase_13 AC 262 ms
96,184 KB
testcase_14 AC 223 ms
93,416 KB
testcase_15 AC 312 ms
100,076 KB
testcase_16 AC 285 ms
98,296 KB
testcase_17 AC 182 ms
89,484 KB
testcase_18 AC 193 ms
90,036 KB
testcase_19 AC 386 ms
99,952 KB
testcase_20 AC 499 ms
108,332 KB
testcase_21 AC 707 ms
105,852 KB
testcase_22 AC 930 ms
114,200 KB
testcase_23 AC 772 ms
109,020 KB
testcase_24 AC 852 ms
110,092 KB
testcase_25 AC 761 ms
111,744 KB
testcase_26 AC 439 ms
111,960 KB
testcase_27 AC 362 ms
97,636 KB
testcase_28 AC 469 ms
117,996 KB
testcase_29 AC 403 ms
107,812 KB
testcase_30 AC 478 ms
110,752 KB
testcase_31 AC 589 ms
114,456 KB
testcase_32 AC 634 ms
111,996 KB
testcase_33 AC 408 ms
109,288 KB
testcase_34 AC 279 ms
100,416 KB
testcase_35 AC 346 ms
99,848 KB
testcase_36 AC 738 ms
110,200 KB
testcase_37 AC 426 ms
109,708 KB
testcase_38 AC 210 ms
90,628 KB
testcase_39 AC 293 ms
98,508 KB
testcase_40 AC 288 ms
98,508 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 363 ms
109,232 KB
testcase_44 AC 371 ms
109,244 KB
testcase_45 AC 364 ms
109,244 KB
testcase_46 AC 371 ms
109,152 KB
testcase_47 AC 421 ms
114,432 KB
testcase_48 AC 432 ms
108,360 KB
権限があれば一括ダウンロードができます

ソースコード

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:
            r = m
        else:
            l = 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[l] and seen[nx] == 0:
                Q.append((nx,cnt+1))
    
    print(w[l],ans)
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0