結果

問題 No.1640 簡単な色塗り
ユーザー stoqstoq
提出日時 2021-08-06 22:34:14
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 3,157 bytes
コンパイル時間 4,964 ms
コンパイル使用メモリ 271,280 KB
実行使用メモリ 49,572 KB
最終ジャッジ日時 2023-09-12 02:31:41
合計ジャッジ時間 25,122 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 85 ms
29,916 KB
testcase_05 AC 85 ms
29,876 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 203 ms
18,984 KB
testcase_11 AC 151 ms
16,444 KB
testcase_12 AC 135 ms
15,324 KB
testcase_13 AC 556 ms
28,248 KB
testcase_14 AC 471 ms
28,244 KB
testcase_15 AC 79 ms
11,620 KB
testcase_16 AC 110 ms
13,736 KB
testcase_17 AC 354 ms
24,188 KB
testcase_18 AC 12 ms
5,164 KB
testcase_19 AC 119 ms
14,880 KB
testcase_20 AC 201 ms
18,472 KB
testcase_21 AC 150 ms
16,124 KB
testcase_22 AC 8 ms
4,652 KB
testcase_23 AC 225 ms
19,604 KB
testcase_24 AC 36 ms
8,056 KB
testcase_25 AC 127 ms
15,360 KB
testcase_26 AC 246 ms
23,016 KB
testcase_27 AC 68 ms
10,988 KB
testcase_28 AC 385 ms
27,540 KB
testcase_29 AC 262 ms
23,128 KB
testcase_30 AC 18 ms
7,764 KB
testcase_31 AC 258 ms
49,572 KB
testcase_32 AC 191 ms
33,648 KB
testcase_33 AC 101 ms
20,816 KB
testcase_34 AC 176 ms
36,392 KB
testcase_35 AC 95 ms
22,192 KB
testcase_36 AC 18 ms
7,508 KB
testcase_37 AC 26 ms
9,580 KB
testcase_38 AC 189 ms
36,632 KB
testcase_39 AC 60 ms
20,784 KB
testcase_40 AC 49 ms
16,012 KB
testcase_41 AC 122 ms
24,616 KB
testcase_42 AC 70 ms
19,480 KB
testcase_43 AC 88 ms
24,284 KB
testcase_44 AC 73 ms
17,340 KB
testcase_45 AC 51 ms
15,048 KB
testcase_46 AC 18 ms
7,940 KB
testcase_47 AC 13 ms
6,636 KB
testcase_48 AC 218 ms
34,932 KB
testcase_49 AC 6 ms
4,612 KB
testcase_50 AC 1 ms
4,380 KB
testcase_51 AC 1 ms
4,380 KB
testcase_52 AC 318 ms
44,724 KB
testcase_53 TLE -
07_evil_01.txt AC 1,328 ms
59,596 KB
07_evil_02.txt TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define MOD_TYPE 1

#pragma region Macros

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

#include <atcoder/all>
using namespace atcoder;

#if 0
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using Int = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
#endif

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//using mint = static_modint<MOD>;
constexpr int INF = (int)1e9 + 10;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

struct io_init
{
  io_init()
  {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(30) << setiosflags(ios::fixed);
  };
} io_init;
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr istream &operator>>(istream &is, pair<T, U> &p) noexcept
{
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

void solve()
{
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n)
  {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }
  const int S = n * 2, T = S + 1;
  mf_graph<int> G(n * 2 + 2);
  rep(i, n)
  {
    G.add_edge(i, a[i] + n, 1);
  }
  rep(i, n)
  {
    G.add_edge(i, b[i] + n, 1);
  }
  rep(i, n)
  {
    G.add_edge(S, i, 1);
    G.add_edge(i + n, T, 1);
  }
  int c = G.flow(S, T);
  if (c != n)
  {
    Yes(0);
    return;
  }
  Yes(1);
  rep(i, n)
  {
    if (G.get_edge(i).flow == 1)
      cout << a[i] + 1 << "\n";
    else
      cout << b[i] + 1 << "\n";
  }
}

int main()
{
  solve();
}
0