結果

問題 No.177 制作進行の宮森あおいです!
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-09-06 21:56:13
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,636 bytes
コンパイル時間 608 ms
コンパイル使用メモリ 73,024 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-27 17:01:05
合計ジャッジ時間 1,096 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
6,940 KB
testcase_03 WA -
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 3 ms
6,944 KB
testcase_06 AC 4 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 WA -
testcase_09 AC 10 ms
6,944 KB
testcase_10 AC 13 ms
6,944 KB
testcase_11 AC 11 ms
6,940 KB
testcase_12 AC 10 ms
6,940 KB
testcase_13 WA -
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void add_edge(int, int, int)’:
main.cpp:18:53: warning: narrowing conversion of ‘G[to].std::vector<edge>::size()’ from ‘std::vector<edge>::size_type’ {aka ‘long unsigned int’} to ‘int’ [-Wnarrowing]
   18 |         G[from].push_back((edge){to, cap, G[to].size()});//from -> to
      |                                           ~~~~~~~~~~^~
main.cpp:19:56: warning: narrowing conversion of ‘(G[from].std::vector<edge>::size() - 1)’ from ‘std::vector<edge>::size_type’ {aka ‘long unsigned int’} to ‘int’ [-Wnarrowing]
   19 |         G[to].push_back((edge){from, 0, G[from].size() - 1});//to -> from
      |                                         ~~~~~~~~~~~~~~~^~~

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cstring>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1e9;
const int MAX_V = 20000;
struct edge{
	int to, cap, rev;
};
vector<edge> G[MAX_V];//隣接リスト
bool used[MAX_V];

void add_edge(int from, int to, int cap){
	G[from].push_back((edge){to, cap, G[to].size()});//from -> to
	G[to].push_back((edge){from, 0, G[from].size() - 1});//to -> from
}

//増加パスを探す
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){
			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;
}
//sからtへの最大流
int max_flow(int s, int t){
	int flow = 0;
	while(1){
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, INF);
		if(f == 0) return flow;
		flow += f;
	}
}

int j[10010], c[10010];
set<int> x[55];
int main(void){
	int w; cin >> w;
	int n; cin >> n;
	rep(i, n) cin >> j[i];
	int m; cin >> m;
	rep(i, m) cin >> c[i];
	rep(i, m){
		int q; cin >> q;
		rep(j, q){
			int tmp; cin >> tmp;
			x[i].insert(tmp);
		}
	}

	//s = 0; t = 200
	rep(i, n) add_edge(0, i + 1, j[i]);//s -> 作画
	rep(i, m) add_edge(100 + i, 200, c[i]);//監督 -> t
	rep(v, m){
		rep(u, n){
			if(x[v].count(u)){//u -> vが許される
				add_edge(u + 1, v + 100, INF);
			}
		}
	}

	ll ans = max_flow(0, 200);
	// printf("%lld\n", ans);
	if(ans + 10>= w) printf("SHIROBAKO\n");
	else printf("BANSAKUTSUKITA\n");
	return 0;
}
0