結果
| 問題 |
No.2387 Yokan Factory
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-21 22:58:21 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,196 bytes |
| コンパイル時間 | 806 ms |
| コンパイル使用メモリ | 84,716 KB |
| 実行使用メモリ | 10,364 KB |
| 最終ジャッジ日時 | 2024-09-22 00:29:58 |
| 合計ジャッジ時間 | 3,778 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 WA * 9 |
コンパイルメッセージ
main.cpp: In function 'bool check(int)':
main.cpp:26:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
26 | for(auto &[u, a, b] : G[v]) {
| ^
main.cpp: In function 'int main()':
main.cpp:46:24: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
46 | int l = 0, r = 1e18+1;
| ~~~~^~
ソースコード
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <tuple>
using namespace std;
using P = pair<int,int>;
using T = tuple<int,int,int>;
const int INF = 1e9;
int N, M, X;
vector<T> G[100005];
int dist[100005];
bool check(int mid) {
fill(dist, dist+N+1, INF);
priority_queue<P, vector<P>, greater<P> > que;
dist[1] = 0;
que.push(P(0, 1));
while(!que.empty()) {
P p = que.top(); que.pop();
int v = p.second;
if(dist[v] < p.first) continue;
for(auto &[u, a, b] : G[v]) {
if(b < mid) continue;
if(dist[u] > dist[v] + a) {
dist[u] = dist[v] + a;
que.push(P(dist[u], u));
}
}
}
return dist[N] <= X;
}
int main() {
cin >> N >> M >> X;
for(int i = 0; i < M; ++i) {
int u, v, a, b;
cin >> u >> v >> a >> b;
G[u].push_back(T(v, a, b));
G[v].push_back(T(u, a, b));
}
int l = 0, r = 1e18+1;
while(r - l > 1) {
int mid = (l + r) / 2;
if(check(mid)) l = mid;
else r = mid;
}
if(l==0) cout << -1 << endl;
else cout << l << endl;
return 0;
}