結果

問題 No.177 制作進行の宮森あおいです!
ユーザー latte0119latte0119
提出日時 2015-08-13 22:09:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,651 bytes
コンパイル時間 1,255 ms
コンパイル使用メモリ 148,320 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 11:28:53
合計ジャッジ時間 2,089 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 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,380 KB
testcase_06 AC 5 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 14 ms
4,376 KB
testcase_11 AC 12 ms
4,376 KB
testcase_12 AC 7 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In member function ‘void Flow::Add_Edge(int, int, int)’:
main.cpp:16:51: warning: narrowing conversion of ‘((Flow*)this)->Flow::G[to].std::vector<Flow::Edge>::size()’ from ‘std::vector<Flow::Edge>::size_type’ {aka ‘long unsigned int’} to ‘int’ inside { } [-Wnarrowing]
         G[from].push_back((Edge){to,cap,G[to].size()});
                                         ~~~~~~~~~~^~
main.cpp:17:53: warning: narrowing conversion of ‘(((Flow*)this)->Flow::G[from].std::vector<Flow::Edge>::size() - 1)’ from ‘std::vector<Flow::Edge>::size_type’ {aka ‘long unsigned int’} to ‘int’ inside { } [-Wnarrowing]
         G[to].push_back((Edge){from,0,G[from].size()-1});
                                       ~~~~~~~~~~~~~~^~

ソースコード

diff #

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

const int MAX_N=200;
const int INF=1e9;

struct Flow{
    struct Edge{
        int to,cap,rev;
    };

    vector<Edge>G[MAX_N];
    bool used[MAX_N];

    void Add_Edge(int from,int to,int cap){
        G[from].push_back((Edge){to,cap,G[to].size()});
        G[to].push_back((Edge){from,0,G[from].size()-1});
    }

    int dfs(int v,int t,int f){
        if(v==t)return f;
        used[v]=true;

        for(int i=0;i<G[v].size();i++){
            Edge &e=G[v][i];
            if(used[e.to]||e.cap==0)continue;
            int _f=dfs(e.to,t,min(f,e.cap));
            if(_f){
                e.cap-=_f;

                G[e.to][e.rev].cap+=_f;
                return _f;
            }
        }
        return 0;
    }

    int Max_Flow(int s,int t){
        int res=0;
        while(true){
            fill_n(used,MAX_N,0);
            int f=dfs(s,t,INF);
            if(f==0)return res;
            res+=f;
        }
    }
};

Flow MF;

int W,N;
int J[50];
int M;
int C[50];

int main(){
    cin>>W>>N;
    for(int i=0;i<N;i++)cin>>J[i];
    cin>>M;
    for(int i=0;i<M;i++)cin>>C[i];

    int s=N+M,t=N+M+1;

    for(int i=0;i<N;i++)MF.Add_Edge(s,i,J[i]);
    for(int i=0;i<M;i++)MF.Add_Edge(i+N,t,C[i]);


    for(int i=0;i<M;i++){
        int Q;cin>>Q;
        bool can[50]={0};
        for(int j=0;j<Q;j++){
            int x;cin>>x;
            can[--x]=true;
        }

        for(int j=0;j<N;j++){
            if(can[j])continue;
            MF.Add_Edge(j,i+N,INF);
        }
    }

    if(MF.Max_Flow(s,t)>=W)cout<<"SHIROBAKO"<<endl;
    else cout<<"BANSAKUTSUKITA"<<endl;



    return 0;
}
0