結果
問題 | No.1473 おでぶなおばけさん |
ユーザー | buey_t |
提出日時 | 2023-03-26 10:51:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 746 ms / 2,000 ms |
コード長 | 2,317 bytes |
コンパイル時間 | 151 ms |
コンパイル使用メモリ | 82,396 KB |
実行使用メモリ | 118,420 KB |
最終ジャッジ日時 | 2024-09-19 09:38:06 |
合計ジャッジ時間 | 21,041 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 128 ms
85,244 KB |
testcase_01 | AC | 122 ms
85,104 KB |
testcase_02 | AC | 590 ms
115,220 KB |
testcase_03 | AC | 418 ms
111,644 KB |
testcase_04 | AC | 351 ms
103,128 KB |
testcase_05 | AC | 259 ms
93,520 KB |
testcase_06 | AC | 525 ms
111,756 KB |
testcase_07 | AC | 524 ms
115,000 KB |
testcase_08 | AC | 588 ms
114,976 KB |
testcase_09 | AC | 532 ms
115,720 KB |
testcase_10 | AC | 302 ms
100,404 KB |
testcase_11 | AC | 352 ms
100,800 KB |
testcase_12 | AC | 289 ms
100,132 KB |
testcase_13 | AC | 255 ms
96,992 KB |
testcase_14 | AC | 219 ms
94,204 KB |
testcase_15 | AC | 304 ms
100,716 KB |
testcase_16 | AC | 276 ms
98,764 KB |
testcase_17 | AC | 176 ms
90,196 KB |
testcase_18 | AC | 189 ms
90,856 KB |
testcase_19 | AC | 351 ms
100,732 KB |
testcase_20 | AC | 411 ms
108,520 KB |
testcase_21 | AC | 576 ms
106,564 KB |
testcase_22 | AC | 746 ms
115,036 KB |
testcase_23 | AC | 650 ms
109,656 KB |
testcase_24 | AC | 698 ms
110,804 KB |
testcase_25 | AC | 650 ms
112,368 KB |
testcase_26 | AC | 413 ms
112,684 KB |
testcase_27 | AC | 336 ms
98,316 KB |
testcase_28 | AC | 423 ms
118,420 KB |
testcase_29 | AC | 382 ms
107,316 KB |
testcase_30 | AC | 425 ms
111,208 KB |
testcase_31 | AC | 520 ms
115,268 KB |
testcase_32 | AC | 508 ms
112,692 KB |
testcase_33 | AC | 353 ms
109,832 KB |
testcase_34 | AC | 275 ms
101,236 KB |
testcase_35 | AC | 310 ms
100,292 KB |
testcase_36 | AC | 588 ms
110,652 KB |
testcase_37 | AC | 370 ms
110,476 KB |
testcase_38 | AC | 204 ms
91,268 KB |
testcase_39 | AC | 288 ms
99,084 KB |
testcase_40 | AC | 274 ms
99,216 KB |
testcase_41 | AC | 293 ms
103,260 KB |
testcase_42 | AC | 265 ms
103,660 KB |
testcase_43 | AC | 354 ms
110,052 KB |
testcase_44 | AC | 349 ms
109,772 KB |
testcase_45 | AC | 358 ms
110,072 KB |
testcase_46 | AC | 338 ms
110,124 KB |
testcase_47 | AC | 378 ms
115,116 KB |
testcase_48 | AC | 378 ms
108,764 KB |
ソースコード
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 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()