結果

問題 No.2387 Yokan Factory
ユーザー polylogK
提出日時 2023-08-02 23:36:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,447 bytes
コンパイル時間 2,012 ms
コンパイル使用メモリ 204,252 KB
最終ジャッジ日時 2025-02-15 21:31:28
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 WA * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:27: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   21 |         int n, m, x; scanf("%d%d%d", &n, &m, &x);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:25:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |                 scanf("%d%d%d%d", &u[i], &v[i], &a[i], &b[i]);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;
#if defined(DONLINE_JUDGE)
#define NDEBUG
#elif defined(ONLINE_JUDGE)
#define NDEBUG
#endif
template<typename T> std::vector<T> make_v(size_t a){return std::vector<T>(a);}
template<typename T, typename... Ts> auto make_v(size_t a, Ts... ts){
return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
int main() {
int n, m, x; scanf("%d%d%d", &n, &m, &x);
std::vector<int> u(m), v(m), a(m), b(m);
std::vector<std::vector<int>> g(n);
for (int i = 0; i < m; ++i) {
scanf("%d%d%d%d", &u[i], &v[i], &a[i], &b[i]);
g[--u[i]].push_back(i);
g[--v[i]].push_back(i);
}
auto f = [&](int t) {
using P = std::pair<i64, int>;
std::priority_queue<P, std::vector<P>, std::greater<P>> qu;
std::vector<i64> costs(n, 1LL << 60); qu.push({costs[0] = 0, 0});
while (!qu.empty()) {
auto [cost, now] = qu.top(); qu.pop();
if (costs[now] != cost) continue;
for (int idx: g[now]) {
int to = u[idx] ^ v[idx] ^ now;
i64 nx = a[idx] + cost;
if (b[idx] < t) continue;
if (costs[to] <= nx) continue;
qu.push({costs[to] = nx, to});
}
}
return costs[n - 1] <= x;
};
int ok = -1, ng = 1 << 30;
while (ng - ok > 1){
int mid = (ok + ng) >> 1;
if (f(mid)) ok = mid;
else ng = mid;
}
printf("%d\n", ok);
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0