結果

問題 No.1984 [Cherry 4th Tune *] Dilemma
ユーザー Kude
提出日時 2022-06-17 23:16:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 1,945 bytes
コンパイル時間 3,183 ms
コンパイル使用メモリ 227,140 KB
最終ジャッジ日時 2025-01-29 22:37:26
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 68
権限があれば一括ダウンロードができます

ソースコード

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