結果

問題 No.654 Air E869120
ユーザー cleaskycleasky
提出日時 2024-02-03 20:42:58
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,261 bytes
コンパイル時間 4,216 ms
コンパイル使用メモリ 272,108 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-03 20:43:04
合計ジャッジ時間 6,556 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main()
{
    cin.tie(0)->sync_with_stdio(0);

    int N, M, d;
    cin >> N >> M >> d;
    vector<int> u(M), v(M), p(M), q(M), w(M);
    for (int i = 0; i < M; i++) {
        cin >> u[i] >> v[i] >> p[i] >> q[i] >> w[i];
        u[i]--;
        v[i]--;
    }
    map<pair<int, int>, int> index; // {city_id, time} -> index of G
    vector<vector<int>> times(N);
    int id = 0;
    index[{ 0, 0 }] = id++;
    times[0].push_back(0);
    times[N - 1].push_back(1e9);
    for (int i = 0; i < M; i++) {
        index[{ u[i], p[i] }] = id++;
        index[{ v[i], q[i] + d }] = id++;
        times[u[i]].push_back(p[i]);
        times[v[i]].push_back(q[i] + d);
    }
    index[{ N - 1, 1e9 }] = id++;
    atcoder::mf_graph<int> G(id);
    for (int i = 0; i < M; i++) {
        G.add_edge(index[{ u[i], p[i] }], index[{ v[i], q[i] + d }], w[i]);
    }
    for (int i = 0; i < N; i++) {
        sort(times[i].begin(), times[i].end());
        for (int j = 0; j < times[i].size() - 1; j++) {
            G.add_edge(index[{ i, times[i][j] }], index[{ i, times[i][j + 1] }], 7 + 1e9);
        }
    }
    int flow = G.flow(index[{ 0, 0 }], index[{ N - 1, 1e9 }]);
    cout << flow << endl;
}
0