結果
問題 | No.2387 Yokan Factory |
ユーザー |
![]() |
提出日時 | 2023-07-21 21:36:00 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,526 ms / 5,000 ms |
コード長 | 1,188 bytes |
コンパイル時間 | 242 ms |
コンパイル使用メモリ | 82,408 KB |
実行使用メモリ | 186,880 KB |
最終ジャッジ日時 | 2024-09-21 22:56:54 |
合計ジャッジ時間 | 22,562 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#############################################################import syssys.setrecursionlimit(10**7)from heapq import heappop,heappushfrom collections import deque,defaultdict,Counterfrom bisect import bisect_left, bisect_rightfrom itertools import product,combinations,permutationsipt = sys.stdin.readlinedef iin():return int(ipt())def lmin():return list(map(int,ipt().split()))inf = 1<<60MOD = 998244353#############################################################N,M,X = lmin()G = [[] for _ in range(N)]for _ in range(M):u,v,a,b = lmin()u,v = u-1,v-1G[u].append((v,a,b))G[v].append((u,a,b))def check(cen):cost = [inf]*Ncost[0] = 0hq = []heappush(hq, (0,0))while hq:t,cur = heappop(hq)if t > cost[cur]:continuefor nxt,a,b in G[cur]:if b < cen:continuent = t+aif nt < cost[nxt]:cost[nxt] = ntheappush(hq, (nt, nxt))return cost[-1] <= Xok = -1ng = 1<<30while ng - ok > 1:cen = (ok+ng)//2if check(cen):ok = cenelse:ng = cenprint(ok)