結果
| 問題 |
No.2387 Yokan Factory
|
| コンテスト | |
| ユーザー |
👑 tatyam
|
| 提出日時 | 2023-07-17 19:42:47 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,311 bytes |
| コンパイル時間 | 2,796 ms |
| コンパイル使用メモリ | 264,464 KB |
| 実行使用メモリ | 19,364 KB |
| 最終ジャッジ日時 | 2024-09-17 21:37:31 |
| 合計ジャッジ時間 | 9,721 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 TLE * 1 -- * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
const i64 INF = LLONG_MAX / 4;
void chmin(i64& a, i64 b) { if(a > b) a = b; }
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
i64 N, M, X;
cin >> N >> M >> X;
vector g(N, vector<array<i64, 3>>{});
vector<i64> width = {-1};
while(M--) {
i64 a, b, d, w;
cin >> a >> b >> d >> w;
a--; b--;
g[a].push_back({b, d, w});
g[b].push_back({a, d, w});
width.push_back(w);
}
sort(width.begin(), width.end());
auto check = [&](i64 i_) -> bool {
const i64 W = width[i_];
vector cost(N, INF);
queue<pair<i64, i64>> q;
auto push = [&](i64 i, i64 c) {
if(cost[i] <= c) return;
cost[i] = c;
q.emplace(c, i);
};
push(0, 0);
while(q.size()) {
auto [c, i] = q.front();
q.pop();
if(cost[i] != c) continue;
for(auto [j, d, w] : g[i]) if(w >= W) push(j, c + d);
}
return cost.back() <= X;
};
i64 ok = 0, ng = width.size();
while(ng - ok > 1) {
const i64 mid = (ok + ng) / 2;
(check(mid) ? ok : ng) = mid;
}
cout << width[ok] << endl;
}
tatyam