結果

問題 No.2387 Yokan Factory
ユーザー miho-4miho-4
提出日時 2023-07-21 22:02:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 635 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 81,588 KB
実行使用メモリ 125,116 KB
最終ジャッジ日時 2023-10-21 22:04:43
合計ジャッジ時間 8,865 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,536 KB
testcase_01 AC 43 ms
55,536 KB
testcase_02 AC 43 ms
55,536 KB
testcase_03 AC 43 ms
55,536 KB
testcase_04 AC 43 ms
55,536 KB
testcase_05 AC 44 ms
55,536 KB
testcase_06 WA -
testcase_07 AC 42 ms
55,536 KB
testcase_08 AC 44 ms
55,536 KB
testcase_09 AC 43 ms
55,536 KB
testcase_10 AC 43 ms
55,536 KB
testcase_11 AC 43 ms
55,536 KB
testcase_12 AC 43 ms
55,536 KB
testcase_13 AC 43 ms
55,536 KB
testcase_14 AC 43 ms
55,536 KB
testcase_15 AC 441 ms
124,884 KB
testcase_16 AC 374 ms
125,116 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

n,m,X=map(int,input().split())
edge=[list(map(int,input().split())) for _ in range(m)]
E=[[] for _ in range(n+1)]
for u,v,a,b in edge:
  E[u].append([v,a,b])
  E[v].append([u,a,b])
  
def f(y):
  D=[float("inf")]*(n+1)
  D[1]=0
  q=deque([1])
  while q:
    x=q.popleft()
    for e,a,b in E[x]:
      if y<=b and D[x]+a<D[e] and D[x]<=X:
        D[e]=D[x]+a
        q.append(e)

  return 0<D[-1]<=X

l,r=0,10**9+1
while 1:
  m=(l+r)//2
  if m<=0:
    exit(print(-1))
  flag=f(m)
  if flag and m==10**9:exit(print(m))
  if flag and f(m+1)==0:
    exit(print(m))
    
  if flag:
    l=m+1
  else:
    r=m-1
0