結果

問題 No.2387 Yokan Factory
ユーザー polylogK
提出日時 2023-08-02 23:37:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 341 ms / 5,000 ms
コード長 1,453 bytes
コンパイル時間 2,136 ms
コンパイル使用メモリ 203,976 KB
最終ジャッジ日時 2025-02-15 21:31:39
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:40: warning: format ‘%lld’ expects argument of type ‘long long int*’, but argument 4 has type ‘i64*’ {aka ‘long int*’} [-Wformat=]
   21 |         int n, m; i64 x; scanf("%d%d%lld", &n, &m, &x);
      |                                     ~~~^           ~~
      |                                        |           |
      |                                        |           i64* {aka long int*}
      |                                        long long int*
      |                                     %ld
main.cpp:21:31: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   21 |         int n, m; i64 x; scanf("%d%d%lld", &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; i64 x; scanf("%d%d%lld", &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 = cost + a[idx];
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