結果

問題 No.654 Air E869120
ユーザー lorent_kyoprolorent_kyopro
提出日時 2021-03-02 10:24:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 1,083 bytes
コンパイル時間 2,465 ms
コンパイル使用メモリ 220,540 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-07-26 14:28:43
合計ジャッジ時間 4,144 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,388 KB
testcase_10 AC 6 ms
4,380 KB
testcase_11 AC 6 ms
4,380 KB
testcase_12 AC 6 ms
4,388 KB
testcase_13 AC 6 ms
4,380 KB
testcase_14 AC 5 ms
4,384 KB
testcase_15 AC 5 ms
4,384 KB
testcase_16 AC 8 ms
4,380 KB
testcase_17 AC 8 ms
4,384 KB
testcase_18 AC 7 ms
4,380 KB
testcase_19 AC 8 ms
4,384 KB
testcase_20 AC 5 ms
4,380 KB
testcase_21 AC 5 ms
4,380 KB
testcase_22 AC 4 ms
4,384 KB
testcase_23 AC 5 ms
4,384 KB
testcase_24 AC 5 ms
4,380 KB
testcase_25 AC 4 ms
4,384 KB
testcase_26 AC 5 ms
4,384 KB
testcase_27 AC 4 ms
4,384 KB
testcase_28 AC 4 ms
4,384 KB
testcase_29 AC 4 ms
4,380 KB
testcase_30 AC 4 ms
4,380 KB
testcase_31 AC 5 ms
4,384 KB
testcase_32 AC 4 ms
4,380 KB
testcase_33 AC 4 ms
4,380 KB
testcase_34 AC 4 ms
4,380 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 1 ms
4,384 KB
testcase_37 AC 1 ms
4,384 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 2 ms
4,384 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<pair<int, int>> us;
    us.emplace_back(0, 0);
    us.emplace_back(n - 1, INT_MAX);
    for (auto& [u, v, p, q, w] : planes) {
        cin >> u >> v >> p >> q >> w;
        u--; v--;
        q += d;
        us.emplace_back(u, p);
        us.emplace_back(v, q);
    }
    sort(us.begin(), us.end());
    us.erase(unique(us.begin(), us.end()), us.end());
    mf_graph<long long> g(us.size());
    for (int i = 0; i < (int)us.size() - 1; ++i) {
        if (us[i].first == us[i + 1].first) {
            g.add_edge(i, i + 1, LLONG_MAX);
        }
    }
    for (auto [u, v, p, q, w] : planes) {
        int i = (int)distance(us.begin(), lower_bound(us.begin(), us.end(), make_pair(u, p)));
        int j = (int)distance(us.begin(), lower_bound(us.begin(), us.end(), make_pair(v, q)));
        g.add_edge(i, j, w);
    }

    cout << g.flow(0, us.size() - 1) << '\n';
}
0