結果
| 問題 |
No.2739 Time is money
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-21 02:47:43 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,045 bytes |
| コンパイル時間 | 2,972 ms |
| コンパイル使用メモリ | 256,548 KB |
| 実行使用メモリ | 20,552 KB |
| 最終ジャッジ日時 | 2024-10-13 01:12:46 |
| 合計ジャッジ時間 | 6,988 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 WA * 2 RE * 1 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using pl=pair<long long,long long>;
using Graph=vector<vector<pl>>;
vector<long long> dijkstra(long long v,long long n,Graph &g){
vector<long long> d(n,8e18);
priority_queue<pl,vector<pl>,greater<pl>> pq;
d[v]=0;
pq.push({0,v});
while(!pq.empty()){
pl od=pq.top();pq.pop();
if(d[od.second]!=od.first){continue;}
for(auto &nx : g[od.second]){
if(d[nx.first]>od.first+nx.second){
d[nx.first]=od.first+nx.second;
pq.push({d[nx.first],nx.first});
}
}
}
return d;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
long long n,m,x;
cin >> n >> m >> x;
x--;
Graph g(n);
for(long long i=0;i<m;i++){
long long u,v,c,t;
cin >> u >> v >> c >> t;
u--;v--;
g[u].push_back({v,t*x+c});
g[v].push_back({u,t*x+c});
}
vector<long long> d=dijkstra(0,n,g);
// for(auto &nx : d){cout << nx << " ";}cout << "\n";
if(d[n-1]>4e18){cout << "-1\n";}
else{
cout << (d[n-1]+x-1)/x << "\n";
}
return 0;
}