結果

問題 No.1744 Selfish Spies 1 (à la Princess' Perfectionism)
ユーザー kotamanegikotamanegi
提出日時 2021-11-14 21:26:48
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,102 bytes
コンパイル時間 6,373 ms
コンパイル使用メモリ 136,836 KB
実行使用メモリ 6,040 KB
最終ジャッジ日時 2023-08-20 05:59:44
合計ジャッジ時間 19,752 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

typedef string::const_iterator State;
#define eps 1e-8L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
#define REP(a, b) for (long long(a) = 0; (a) < (b); ++(a))
#define ALL(x) (x).begin(), (x).end()

#include "atcoder/maxflow.hpp"
using namespace atcoder;

#define int long long
void solve()
{
  int n, m, l;
  cin >> n >> m >> l;
  vector<pair<int, int>> edges;
  REP(i, l)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edges.push_back({a, b});
  }

  mf_graph<int> main_graph(n + m + 2);
  REP(i, l)
  {
    main_graph.add_edge(edges[i].first, n + edges[i].second, 1);
  }
  REP(i, n)
  {
    main_graph.add_edge(n + m, i, 1);
  }
  REP(i, m)
  {
    main_graph.add_edge(n + i, n + m + 1, 1);
  }
  int expected_value = main_graph.flow(n + m, n + m + 1);
  cout << expected_value << endl;
  vector<bool> ans(l, true);
  REP(i, l)
  {
    if (main_graph.get_edge(i).flow == 0)
    {
      continue;
    }
    mf_graph<int> sub_graph(n + m + 2);
    REP(q, l)
    {
      if (i == q)
        continue;
      sub_graph.add_edge(edges[q].first, n + edges[q].second, 1);
    }
    REP(i, n)
    {
      sub_graph.add_edge(n + m, i, 1);
    }
    REP(i, m)
    {
      sub_graph.add_edge(n + i, n + m + 1, 1);
    }
    if (sub_graph.flow(n + m, n + m + 1) != expected_value)
    {
      ans[i] = false;
    }
  }
  REP(i, l)
  {
    if (ans[i] == true)
    {
      cout << "Yes" << endl;
    }
    else
    {
      cout << "No" << endl;
    }
  }
}
#undef int

// generated by oj-template v4.7.2
// (https://github.com/online-judge-tools/template-generator)
int main()
{
  // Fasterize input/output script
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(100);
  // scanf/printf user should delete this fasterize input/output script

  int t = 1;
  // cin >> t; // comment out if solving multi testcase
  for (int testCase = 1; testCase <= t; ++testCase)
  {
    solve();
  }
  return 0;
}
0