結果

問題 No.177 制作進行の宮森あおいです!
ユーザー 👑 CleyL
提出日時 2023-10-06 23:29:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 3,039 bytes
コンパイル時間 1,355 ms
コンパイル使用メモリ 124,644 KB
最終ジャッジ日時 2025-02-17 05:42:12
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

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)intiteriter
*/
/*
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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0