結果
| 問題 |
No.177 制作進行の宮森あおいです!
|
| コンテスト | |
| ユーザー |
sugim48
|
| 提出日時 | 2015-04-02 23:39:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 15 ms / 2,000 ms |
| コード長 | 2,212 bytes |
| コンパイル時間 | 807 ms |
| コンパイル使用メモリ | 96,748 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-04 01:27:51 |
| 合計ジャッジ時間 | 1,426 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
コンパイルメッセージ
main.cpp: In member function ‘void flow_network::add_edge(int, int, ll)’:
main.cpp:40:42: warning: narrowing conversion of ‘(&((flow_network*)this)->flow_network::G.std::vector<std::vector<flow_network::edge> >::operator[](((std::vector<std::vector<flow_network::edge> >::size_type)v)))->std::vector<flow_network::edge>::size()’ from ‘std::vector<flow_network::edge>::size_type’ {aka ‘long unsigned int’} to ‘int’ [-Wnarrowing]
40 | edge e = {v, c, G[v].size()}, _e = {u, 0, G[u].size()};
| ~~~~~~~~~^~
main.cpp:40:68: warning: narrowing conversion of ‘(&((flow_network*)this)->flow_network::G.std::vector<std::vector<flow_network::edge> >::operator[](((std::vector<std::vector<flow_network::edge> >::size_type)u)))->std::vector<flow_network::edge>::size()’ from ‘std::vector<flow_network::edge>::size_type’ {aka ‘long unsigned int’} to ‘int’ [-Wnarrowing]
40 | edge e = {v, c, G[v].size()}, _e = {u, 0, G[u].size()};
| ~~~~~~~~~^~
ソースコード
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
struct flow_network {
int n;
struct edge { int v; ll c; int rev; };
vector< vector<edge> > G;
flow_network(int _n) : n(_n), G(_n) {}
void add_edge(int u, int v, ll c) {
edge e = {v, c, G[v].size()}, _e = {u, 0, G[u].size()};
G[u].push_back(e); G[v].push_back(_e);
}
ll dfs(int u, int t, ll f, vector<bool>& vis) {
if (u == t) return f;
vis[u] = true;
for (int i = 0; i < G[u].size(); i++) {
edge& e = G[u][i];
if (vis[e.v] || e.c == 0) continue;
ll d = min(e.c, dfs(e.v, t, min(f, e.c), vis));
if (d == 0) continue;
e.c -= d;
G[e.v][e.rev].c += d;
return d;
}
return 0;
}
ll max_flow(int s, int t) {
ll res = 0;
for (;;) {
vector<bool> vis(n);
ll f = dfs(s, t, LLONG_MAX, vis);
if (f == 0) return res;
res += f;
}
}
};
int main() {
int W; cin >> W;
int N; cin >> N;
vector<int> J(N);
for (int i = 0; i < N; i++)
cin >> J[i];
int M; cin >> M;
vector<int> C(M);
for (int j = 0; j < M; j++)
cin >> C[j];
vector<set<int> > X(M);
for (int j = 0; j < M; j++) {
int Q; cin >> Q;
while (Q--) {
int x; cin >> x;
X[j].insert(x - 1);
}
}
flow_network fn(N + M + 3);
int s = N + M, t = N + M + 1, ss = N + M + 2;
for (int i = 0; i < N; i++)
fn.add_edge(s, i, J[i]);
for (int j = 0; j < M; j++)
fn.add_edge(N + j, t, C[j]);
for (int j = 0; j < M; j++)
for (int i = 0; i < N; i++) {
if (X[j].count(i)) continue;
fn.add_edge(i, N + j, 10000);
}
fn.add_edge(ss, s, W);
int x = fn.max_flow(ss, t);
cout << (x == W ? "SHIROBAKO" : "BANSAKUTSUKITA") << endl;
}
sugim48