結果
問題 | No.654 Air E869120 |
ユーザー |
|
提出日時 | 2023-12-20 23:20:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 2,528 bytes |
コンパイル時間 | 4,565 ms |
コンパイル使用メモリ | 262,992 KB |
最終ジャッジ日時 | 2025-02-18 12:48:56 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace atcoder;#ifdef LOCAL#include <debug.h>#define dbg(...) debug::dbg(#__VA_ARGS__, __VA_ARGS__)#else#define dbg(...) void(0)#endifusing namespace std;// #define int ll#define rep(i, a, b) for(int i=static_cast<int>(a), i##_end__=static_cast<int>(b); i < i##_end__; i++)#define rep_r(i, a, b) for(int i=static_cast<int>(a), i##_end__=static_cast<int>(b); i >= i##_end__; i--)#define fore(i, a) for(auto& i: a)#define all(x) std::begin(x), std::end(x)using ll = long long; // __int128;using ull = unsigned long long;template<class C> int siz(const C& c) { return static_cast<int>(c.size()); }template<class T, size_t N> constexpr int siz(const T (&)[N]) { return static_cast<int>(N); }template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }template<class T> constexpr T pow2(T x){ return x * x; }template<class T, class S> constexpr T divceil(T x, S div) { return (x % div == 0) ? x / div : (x >= 0) ? (x / div) + 1 : -((-x) / div); }template<class T, class S> constexpr T divfloor(T x, S div){ return (x % div == 0) ? x / div : (x >= 0) ? (x / div) : -((-x) / div) - 1; }template<class T> inline void oneline(T x){ bool f = true; for(auto i: x){ if(f) f = false; else cout << " "; cout << i; } cout << endl; }inline void yesno(bool x){ cout << (x ? "Yes" : "No") << endl; }constexpr long long INF = 1LL << 60; // 1.15e18constexpr int MOD = (int)1e9 + 7;void _main() {int N, M, d;cin >> N >> M >> d;vector<vector<tuple<int, int, int, int, int>>> G(N);auto S = 2 * M;auto T = 2 * M + 1;mf_graph<ll> mf(T + 1);rep(id, 0, M){int u, v, p, q, w;cin >> u >> v >> p >> q >> w;u--; v--;G[u].push_back({v, p, q, w, id});if(u == 0 ) mf.add_edge(S, id, INF);if(v == N - 1) mf.add_edge(M + id, T, INF);mf.add_edge(id, M + id, w);}rep(i, 0, N){for(auto [fv, fp, fq, fw, fid]: G[i]){for(auto [tv, tp, tq, tw, tid]: G[fv]){if(fq + d <= tp) mf.add_edge(M + fid, tid, INF);}}}auto maxflow = mf.flow(S, T);cout << maxflow << endl;dbg(G);dbg(N, M, d, S, T, mf.edges());}signed main() {cin.tie(nullptr); ios::sync_with_stdio(false);cout << fixed << setprecision(15); cerr << fixed << setprecision(15);_main();}