結果
| 問題 |
No.2387 Yokan Factory
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-21 21:50:55 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 2,886 ms / 5,000 ms |
| コード長 | 1,148 bytes |
| コンパイル時間 | 344 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 189,312 KB |
| 最終ジャッジ日時 | 2024-09-21 23:19:58 |
| 合計ジャッジ時間 | 30,309 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random
#sys.setrecursionlimit(10**9)
#n = int(input())
#alist = list(map(int,input().split()))
#alist = []
#s = input()
n,m,X = map(int,input().split())
edge = [[] for i in range(n)]
for i in range(m):
u,v,a,b = map(int,input().split())
u,v = u-1,v-1
edge[u].append((v,a,b))
edge[v].append((u,a,b))
#for i in range(n):
# alist.append(list(map(int,input().split())))
class nibutan():
def __init__(self):
self.max = 10**9+10
def __len__(self):
return self.max
def __getitem__(self,x):
d = []
d.append((0,0))
dist = [10**18] * n
dist[0] = 0
while d:
_,now = heapq.heappop(d)
if _ > dist[now]:
continue
for i in edge[now]:
if i[2] < x:
continue
if dist[now] + i[1] < dist[i[0]]:
dist[i[0]] = dist[now] + i[1]
heapq.heappush(d,(dist[i[0]],i[0]))
return 1 if dist[-1] > X else 0
print(bisect.bisect_left(nibutan(),1)-1)