提出 #23390951


ソースコード 拡げる

#include <iostream>
#include <vector>
#include <atcoder/maxflow>
using namespace std;

int get_index() {
    static int id = -1;
    id += 1;
    return id;
}

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> A(N), B(N), C(N), D(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        A[i] -= 1;
        B[i] -= 1;
    }
    const int src = get_index();
    const int dst = get_index();
    vector<int> row(H), col(W);
    for (int i = 0; i < H; ++i) {
        row[i] = get_index();
    }
    for (int i = 0; i < W; ++i) {
        col[i] = get_index();
    }
    vector<int> token_r(N), token_c(N);
    for (int i = 0; i < N; ++i) {
        token_r[i] = get_index();
        token_c[i] = get_index();
    }
    atcoder::mf_graph<int> graph(get_index());
    for (int i = 0; i < H; ++i) {
        graph.add_edge(src, row[i], 1);
    }
    for (int i = 0; i < W; ++i) {
        graph.add_edge(col[i], dst, 1);
    }
    for (int i = 0; i < N; ++i) {
        for (int j = A[i]; j < C[i]; ++j) {
            graph.add_edge(row[j], token_r[i], 1);
        }
        graph.add_edge(token_r[i], token_c[i], 1);
        for (int j = B[i]; j < D[i]; ++j) {
            graph.add_edge(token_c[i], col[j], 1);
        }
    }
    cout << graph.flow(src, dst) << '\n';
}

提出情報

提出日時
問題 F - Grid and Tokens
ユーザ KoD
言語 C++ (GCC 9.2.1)
得点 600
コード長 1365 Byte
結果 AC
実行時間 8 ms
メモリ 4044 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 600 / 600
結果
AC × 2
AC × 44
セット名 テストケース
Sample example_00.txt, example_01.txt
All bound_00.txt, bound_01.txt, bound_02.txt, bound_03.txt, example_00.txt, example_01.txt, handmade_00.txt, loose_00.txt, loose_01.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, smallgrid_00.txt, smallgrid_01.txt, smallgrid_02.txt, smallgrid_03.txt, smallgrid_04.txt, smallgrid_05.txt, smallgrid_06.txt, smallgrid_07.txt, smallgrid_08.txt, smallgrid_09.txt, tight_00.txt, tight_01.txt, tight_02.txt, tight_03.txt, tight_04.txt
ケース名 結果 実行時間 メモリ
bound_00.txt AC 8 ms 3416 KiB
bound_01.txt AC 3 ms 3824 KiB
bound_02.txt AC 4 ms 3824 KiB
bound_03.txt AC 3 ms 4044 KiB
example_00.txt AC 3 ms 3604 KiB
example_01.txt AC 3 ms 3412 KiB
handmade_00.txt AC 3 ms 3720 KiB
loose_00.txt AC 5 ms 3672 KiB
loose_01.txt AC 3 ms 3456 KiB
random_00.txt AC 2 ms 3564 KiB
random_01.txt AC 3 ms 3620 KiB
random_02.txt AC 2 ms 3568 KiB
random_03.txt AC 3 ms 3540 KiB
random_04.txt AC 4 ms 3672 KiB
random_05.txt AC 2 ms 3596 KiB
random_06.txt AC 2 ms 3596 KiB
random_07.txt AC 2 ms 3536 KiB
random_08.txt AC 5 ms 3648 KiB
random_09.txt AC 2 ms 3560 KiB
random_10.txt AC 4 ms 3636 KiB
random_11.txt AC 2 ms 3688 KiB
random_12.txt AC 2 ms 3580 KiB
random_13.txt AC 3 ms 3708 KiB
random_14.txt AC 4 ms 3612 KiB
random_15.txt AC 3 ms 3808 KiB
random_16.txt AC 4 ms 3712 KiB
random_17.txt AC 3 ms 3708 KiB
random_18.txt AC 4 ms 3760 KiB
random_19.txt AC 3 ms 3804 KiB
smallgrid_00.txt AC 2 ms 3520 KiB
smallgrid_01.txt AC 2 ms 3540 KiB
smallgrid_02.txt AC 2 ms 3608 KiB
smallgrid_03.txt AC 6 ms 3616 KiB
smallgrid_04.txt AC 2 ms 3616 KiB
smallgrid_05.txt AC 2 ms 3532 KiB
smallgrid_06.txt AC 2 ms 3484 KiB
smallgrid_07.txt AC 2 ms 3648 KiB
smallgrid_08.txt AC 2 ms 3496 KiB
smallgrid_09.txt AC 2 ms 3548 KiB
tight_00.txt AC 2 ms 3612 KiB
tight_01.txt AC 2 ms 3612 KiB
tight_02.txt AC 3 ms 3508 KiB
tight_03.txt AC 2 ms 3548 KiB
tight_04.txt AC 2 ms 3512 KiB