結果

問題 No.1984 [Cherry 4th Tune *] Dilemma
ユーザー KudeKude
提出日時 2022-06-17 23:16:18
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,945 bytes
コンパイル時間 2,802 ms
コンパイル使用メモリ 236,940 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-08 08:22:01
合計ジャッジ時間 11,025 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,384 KB
testcase_25 AC 2 ms
4,384 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,384 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,384 KB
testcase_30 AC 2 ms
4,384 KB
testcase_31 AC 2 ms
4,384 KB
testcase_32 AC 2 ms
4,384 KB
testcase_33 AC 1 ms
4,384 KB
testcase_34 AC 2 ms
4,384 KB
testcase_35 AC 2 ms
4,384 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 2 ms
4,384 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 2 ms
4,384 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 2 ms
4,384 KB
testcase_45 AC 1 ms
4,384 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 1 ms
4,384 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 2 ms
4,384 KB
testcase_50 AC 2 ms
4,384 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 AC 2 ms
4,384 KB
testcase_53 AC 2 ms
4,384 KB
testcase_54 AC 2 ms
4,380 KB
testcase_55 AC 2 ms
4,380 KB
testcase_56 AC 2 ms
4,380 KB
testcase_57 AC 2 ms
4,384 KB
testcase_58 AC 2 ms
4,384 KB
testcase_59 AC 2 ms
4,384 KB
testcase_60 AC 2 ms
4,380 KB
testcase_61 AC 1 ms
4,380 KB
testcase_62 AC 2 ms
4,384 KB
testcase_63 AC 2 ms
4,384 KB
testcase_64 AC 2 ms
4,380 KB
testcase_65 AC 2 ms
4,384 KB
testcase_66 AC 2 ms
4,380 KB
testcase_67 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic pop
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;

} int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k, p;
  cin >> n >> m >> k >> p;
  VI e(n), f(m), v(k);
  rep(i, n) cin >> e[i];
  rep(i, m) cin >> f[i];
  rep(i, k) cin >> v[i];
  const int se = 0, sf = n, sv = sf + m, s = sv + k, t = s + 1;
  mf_graph<ll> g(t + 1);
  rep(i, k) g.add_edge(s, sv + i, v[i]);
  ll ans = accumulate(all(e), 0LL) + accumulate(all(f), 0LL);
  rep(i, n) g.add_edge(se + i, t, e[i]);
  rep(i, m) g.add_edge(s, sf + i, f[i]);
  constexpr ll INF = 100LL * 1001001001;
  rep(i, n) {
    int l;
    cin >> l;
    rep(_, l) {
      int ai;
      cin >> ai;
      ai--;
      g.add_edge(sv + ai, se + i, INF);
    }
  }
  rep(_, p) {
    int i, j;
    cin >> i >> j;
    i--, j--;
    g.add_edge(sf + j, se + i, INF);
  }
  auto flow = g.flow(s, t);
  ans -= flow;
  cout << ans << '\n';
  vector<P> ms;
  auto c = g.min_cut(s);
  rep(i, k) if (!c[sv + i]) {
    ms.emplace_back(0, i);
  }
  rep(i, n) if (!c[se + i]) {
    ms.emplace_back(1, i);
  }
  rep(i, m) if (c[sf + i]) {
    ms.emplace_back(2, i);
  }
  cout << ms.size() << '\n';
  for(auto [t, i]: ms) {
    cout << (t == 0 ? "Preparation" : t == 1 ? "Goal" : "Action") << ' ' << i + 1 << '\n';
  }
}
0