結果

問題 No.654 Air E869120
ユーザー lorent_kyoprolorent_kyopro
提出日時 2021-03-02 10:16:39
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 1,225 bytes
コンパイル時間 2,730 ms
コンパイル使用メモリ 218,992 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 04:29:17
合計ジャッジ時間 4,388 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 6 ms
6,940 KB
testcase_11 AC 6 ms
6,940 KB
testcase_12 AC 6 ms
6,940 KB
testcase_13 AC 6 ms
6,940 KB
testcase_14 AC 5 ms
6,944 KB
testcase_15 AC 6 ms
6,940 KB
testcase_16 AC 7 ms
6,940 KB
testcase_17 AC 9 ms
6,944 KB
testcase_18 AC 8 ms
6,944 KB
testcase_19 AC 8 ms
6,940 KB
testcase_20 AC 5 ms
6,944 KB
testcase_21 AC 5 ms
6,940 KB
testcase_22 AC 4 ms
6,944 KB
testcase_23 AC 5 ms
6,944 KB
testcase_24 AC 5 ms
6,940 KB
testcase_25 AC 5 ms
6,940 KB
testcase_26 AC 4 ms
6,940 KB
testcase_27 AC 4 ms
6,940 KB
testcase_28 AC 4 ms
6,944 KB
testcase_29 AC 5 ms
6,940 KB
testcase_30 AC 4 ms
6,940 KB
testcase_31 AC 4 ms
6,944 KB
testcase_32 AC 4 ms
6,944 KB
testcase_33 AC 4 ms
6,940 KB
testcase_34 AC 4 ms
6,944 KB
testcase_35 AC 2 ms
6,940 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 2 ms
6,944 KB
testcase_38 AC 2 ms
6,944 KB
testcase_39 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#include <atcoder/maxflow>
using namespace atcoder;

int main() {
    int n, m, d;
    cin >> n >> m >> d;

    vector<tuple<int, int, int, int, int>> planes(m);
    vector<vector<int>> us(n);
    us[0].push_back(0);
    us[n - 1].push_back(INT_MAX);
    for (auto& [u, v, p, q, w] : planes) {
        cin >> u >> v >> p >> q >> w;
        u--; v--;
        us[u].push_back(p);
        us[v].push_back(q + d);
    }

    vector<int> id(n + 1);
    for (int i = 0; i < n; ++i) {
        sort(us[i].begin(), us[i].end());
        us[i].erase(unique(us[i].begin(), us[i].end()), us[i].end());
        id[i + 1] = id[i] + (int)us[i].size();
    }

    mf_graph<long long> g(id[n]);
    int s = 0, t = id[n] - 1;

    for (int i = 0; i < n; ++i) {
        for (int u = id[i]; u + 1 < id[i] + (int)us[i].size(); ++u) {
            g.add_edge(u, u + 1, LLONG_MAX);
        }
    }

    for (auto [u, v, p, q, w] : planes) {
        int i = distance(us[u].begin(), lower_bound(us[u].begin(), us[u].end(), p));
        int j = distance(us[v].begin(), lower_bound(us[v].begin(), us[v].end(), q + d));
        g.add_edge(id[u] + i, id[v] + j, w);
    }

    cout << g.flow(s, t) << '\n';
}
0