結果

問題 No.177 制作進行の宮森あおいです!
ユーザー kokoseikokosei
提出日時 2023-11-05 13:59:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,061 bytes
コンパイル時間 1,334 ms
コンパイル使用メモリ 91,424 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-11-05 13:59:47
合計ジャッジ時間 2,493 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 2 ms
4,372 KB
testcase_06 AC 2 ms
4,372 KB
testcase_07 AC 2 ms
4,372 KB
testcase_08 AC 2 ms
4,372 KB
testcase_09 AC 2 ms
4,372 KB
testcase_10 AC 3 ms
4,372 KB
testcase_11 AC 3 ms
4,372 KB
testcase_12 AC 2 ms
4,372 KB
testcase_13 AC 2 ms
4,372 KB
testcase_14 AC 2 ms
4,372 KB
testcase_15 AC 2 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <atcoder/maxflow>
using namespace std;
using ll = long long;
const int mod = 998244353;
const int inf = 1 << 28;

int W, N, M;
int J[60], C[60];
bool X[60][60];
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> W;
    cin >> N;
    for(int i = 0;i < N;i++)cin >> J[i];
    cin >> M;
    for(int i = 0;i < M;i++)cin >> C[i];
    for(int i = 0;i < M;i++){
        for(int j = 0;j < N;j++)X[j][i] = true;
        int q; cin >> q;
        for(int j = 0;j < q;j++){
            int x; cin >> x; x--;
            X[x][i] = false;
        }
    }
    atcoder::mf_graph<int> G(N + M + 2);
    int sv = N + M, tv = N + M + 1;
    for(int i = 0;i < N;i++){
        G.add_edge(sv, i, J[i]);
    }
    for(int i = 0;i < M;i++){
        G.add_edge(N + i, tv, C[i]);
    }
    for(int i = 0;i < N;i++){
        for(int j = 0;j < M;j++){
            if(X[i][j])G.add_edge(i, N + j, inf);
        }
    }
    int v = G.flow(sv, tv);
    cout << (v >= W ? "SHIROBAKO" : "BANSAKUTSUKITA") << "\n";
    return 0;
}
0