結果
問題 | No.2739 Time is money |
ユーザー |
|
提出日時 | 2024-04-20 19:53:36 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,013 bytes |
コンパイル時間 | 185 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 298,316 KB |
最終ジャッジ日時 | 2024-10-12 17:50:40 |
合計ジャッジ時間 | 22,242 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 6 WA * 2 TLE * 7 -- * 3 |
ソースコード
from collections import deque,defaultdict N,M,X=map(int,input().split()) G=[[] for _ in range(N)] C=defaultdict(int) T=defaultdict(int) for _ in range(M): u,v,c,t=map(int,input().split()) u-=1;v-=1 G[u].append(v) G[v].append(u) C[(u,v)]=c C[(v,u)]=c T[(u,v)]=t T[(v,u)]=t vis=[(-1,-1,-1) for _ in range(N)] attr=defaultdict(tuple) Q=deque() attr[0]=(0,0,0) Q.append(0) while Q: now=Q.popleft() m,c,t=attr[now] del attr[now] vis[now]=(m,c,t) for nxt in G[now]: if c+C[(now,nxt)]>m: work=(m-c+C[(now,nxt)]+X-1)//X else: work=0 if vis[nxt]==(-1,-1,-1) or t+T[(now,nxt)]+work<vis[nxt][2]: if nxt in attr.keys(): mm,cc,tt=attr[nxt] if t+T[(now,nxt)]+work<tt: attr[nxt]=(m+X*work,c+C[(now,nxt)],t+T[(now,nxt)]+work) else: attr[nxt]=(m+X*work,c+C[(now,nxt)],t+T[(now,nxt)]+work) Q.append(nxt) print(vis[N-1][2])