結果
問題 | No.177 制作進行の宮森あおいです! |
ユーザー |
![]() |
提出日時 | 2015-07-19 18:40:23 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,890 bytes |
コンパイル時間 | 471 ms |
コンパイル使用メモリ | 50,304 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-08 10:22:19 |
合計ジャッジ時間 | 926 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 WA * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:59:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 59 | scanf("%d", &W); | ~~~~~^~~~~~~~~~ main.cpp:60:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 60 | scanf("%d", &N); | ~~~~~^~~~~~~~~~ main.cpp:62:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 62 | scanf("%d", J+i); | ~~~~~^~~~~~~~~~~ main.cpp:64:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 64 | scanf("%d", &M); | ~~~~~^~~~~~~~~~ main.cpp:66:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 66 | scanf("%d", C+i); | ~~~~~^~~~~~~~~~~ main.cpp:79:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 79 | scanf("%d", &q); | ~~~~~^~~~~~~~~~ main.cpp:86:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 86 | scanf("%d", &x); | ~~~~~^~~~~~~~~~
ソースコード
// Ford-Fulkerson法#include <cstdio>#include <vector>#include <algorithm>#include <cstring>#include <tuple>typedef std::tuple<int,int,int> P;int W, N, M;int J[51], C[51];// [0, N): 原画// [N, N+M): 作画監督// N+M: 始点// N+M+1: 終点std::vector<P> G[200];bool visited[200];int INF = 252521;void addEdge(int from, int to, int cap){G[from].emplace_back(to, cap, G[to].size());G[to].emplace_back(from, cap, G[from].size()-1);}int dfs(int v, int f){if(v == N+M+1){return f;}visited[v] = true;for(auto &e : G[v]){int to, cap, rev;std::tie(to, cap, rev) = e;if(visited[to]){continue;}if(cap == 0){continue;}int res = dfs(to, std::min(f, cap));std::get<1>(e) -= res;std::get<1>(G[to][rev]) += res;return res;}return 0;}int maxFlow(){int f = 0;while(1){memset(visited, 0, sizeof(visited));int x = dfs(N+M, INF);if(x == 0){return f;}f += x;}}int main(){scanf("%d", &W);scanf("%d", &N);for(int i=0;i<N;i++){scanf("%d", J+i);}scanf("%d", &M);for(int i=0;i<M;i++){scanf("%d", C+i);}for(int i=0;i<M;i++){addEdge(i+N, N+M+1, C[i]);}for(int i=0;i<N;i++){addEdge(N+M, i, J[i]);}for(int i=0;i<M;i++){int q;scanf("%d", &q);bool flags[51];std::fill(flags, flags+51, false);for(int j=0;j<q;j++){int x;scanf("%d", &x);x -= 1;flags[x] = true;}for(int j=0;j<N;j++){if(flags[j]){continue;}addEdge(j, i+N, J[j]);}}// printf("%d\n", maxFlow());if(maxFlow() >= W){puts("SHIROBAKO");}else{puts("BANSAKUTSUKITA");}}