結果

問題 No.177 制作進行の宮森あおいです!
ユーザー CleyLCleyL
提出日時 2023-10-06 23:29:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 3,039 bytes
コンパイル時間 1,362 ms
コンパイル使用メモリ 127,552 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-10-06 23:30:02
合計ジャッジ時間 2,214 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 4 ms
4,380 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 15 ms
4,384 KB
testcase_11 AC 13 ms
4,380 KB
testcase_12 AC 7 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

#include <cmath>
#include <algorithm>

#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>

#include <bitset>

#include <complex>

#include <cctype>
#include <utility>
#include <climits>

#include <numeric>

#include <functional>

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 998244353;
const ll MODx = 1000000007;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62LL)-1;
const double EPS = (1e-10);

P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};




template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }
 
 /*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/

/*
function corner below
*/


/*
Function corner above
*/

/* comment outed because can cause bugs
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
*/

// 蟻本参照
template <int MAX_V = 1000>
struct FoldFulkerson {
  struct edge { int to, cap, rev_i; };
  int n;
  vector<edge> G[MAX_V];
  vector<int> lck;

  FoldFulkerson(int n): n(n), lck(n, 0){}

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

  int dfs(int v, int t, int f){
    if(v == t)return f;
    lck[v] = true;
    for(int i = 0; G[v].size() > i; i++){
      auto& e = G[v][i];
      if (!lck[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_i].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  int max_flow(int s, int t){
    int flow = 0;
    while(true){
      lck.assign(n, false);
      int f = dfs(s, t, INF);
      if(!f)return flow;
      flow += f;
    }
  }
};

int main(){
  int w;cin>>w;
  int n;cin>>n;
  vector<int> J(n);
  for(int i = 0; n > i; i++)cin>>J[i];
  int m;cin>>m;
  vector<int> C(m);
  for(int i = 0; m > i; i++)cin>>C[i];
  FoldFulkerson flow(1 + n + m + 1);
  for(int i = 0; n > i; i++){
    flow.push(0, i+1, J[i]);
  }
  for(int i = 0; m > i; i++){
    flow.push(1 + n + i, 1 + n + m, C[i]);
  }
  for(int i = 0; m > i; i++){
    int q;cin>>q;
    int nw;cin>>nw;
    int z = 1;
    for(int j = 1; n >= j; j++){
      if(nw == j){
        if(z == q)continue;
        cin>>nw;
        z++;
      }else{
        flow.push(j, 1 + n + i, J[j-1]);
      }
    }
  }
  int x = flow.max_flow(0, 1 + n + m);
  cout << (x>=w ? "SHIROBAKO" : "BANSAKUTSUKITA") << endl;
  return 0;
}
0