結果

問題 No.177 制作進行の宮森あおいです!
ユーザー Div9851Div9851
提出日時 2015-04-03 00:23:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,375 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 46,812 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-17 03:48:51
合計ジャッジ時間 1,127 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;
struct edge {
	int to,cap,rev;
	edge(int TO,int CAP,int REV) {
		to=TO,cap=CAP,rev=REV;
	}
};
bool used[102];
bool poyo[102][102];
vector<edge> G[102];
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]=1;
	for(int i=0;i<G[v].size();i++) {
		edge &e=G[v][i];
		if(!used[e.to]&&e.cap>0) {
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0) {
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s,int t) {
	int flow=0;
	for(;;) {
		memset(used,0,sizeof(used));
		int f=dfs(s,t,1<<30);
		if(f==0) return flow;
		flow+=f;
	}
}
int main() {
	int W,N,M;
	scanf("%d %d",&W,&N);
	for(int i=1;i<=N;i++) {
		int J;
		scanf("%d",&J);
		add_edge(0,i,J);
	}
	scanf("%d",&M);
	for(int i=1;i<=M;i++) {
		int C;
		scanf("%d",&C);
		add_edge(N+i,N+M+1,C);
	}
	for(int i=1;i<=M;i++) {
		int Q;
		scanf("%d",&Q);
		for(int j=1;j<=Q;j++) {
			int X;
			scanf("%d",&X);
			poyo[X][N+i]=1;
		}
	}
	for(int i=1;i<=N;i++) {
		for(int j=1;j<=M;j++) {
			if(!poyo[i][N+j]) add_edge(i,N+j,1<<30);
		}
	}
	if(max_flow(0,N+M+1)>=W) {
		printf("SHIROBAKO\n");
	}else {
		printf("BANSAKUTSUKITA\n");
	}
}
0