結果
問題 | No.177 制作進行の宮森あおいです! |
ユーザー |
![]() |
提出日時 | 2015-04-03 00:23:28 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 1,375 bytes |
コンパイル時間 | 304 ms |
コンパイル使用メモリ | 43,392 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-04 01:30:00 |
合計ジャッジ時間 | 932 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:47:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 47 | scanf("%d %d",&W,&N); | ~~~~~^~~~~~~~~~~~~~~ main.cpp:50:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 50 | scanf("%d",&J); | ~~~~~^~~~~~~~~ main.cpp:53:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 53 | scanf("%d",&M); | ~~~~~^~~~~~~~~ main.cpp:56:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 56 | scanf("%d",&C); | ~~~~~^~~~~~~~~ main.cpp:61:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 61 | scanf("%d",&Q); | ~~~~~^~~~~~~~~ main.cpp:64:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 64 | scanf("%d",&X); | ~~~~~^~~~~~~~~
ソースコード
#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");}}