結果

問題 No.1640 簡単な色塗り
ユーザー 👑 NachiaNachia
提出日時 2021-08-06 21:30:19
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 929 bytes
コンパイル時間 1,510 ms
コンパイル使用メモリ 91,684 KB
実行使用メモリ 45,292 KB
最終ジャッジ日時 2023-09-12 01:36:28
合計ジャッジ時間 13,427 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 82 ms
30,768 KB
testcase_05 AC 84 ms
30,680 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 153 ms
19,068 KB
testcase_11 AC 118 ms
16,264 KB
testcase_12 AC 100 ms
14,888 KB
testcase_13 AC 316 ms
27,824 KB
testcase_14 AC 317 ms
27,628 KB
testcase_15 AC 67 ms
11,528 KB
testcase_16 AC 81 ms
13,696 KB
testcase_17 AC 238 ms
24,004 KB
testcase_18 AC 11 ms
5,112 KB
testcase_19 AC 103 ms
14,824 KB
testcase_20 AC 159 ms
18,664 KB
testcase_21 AC 113 ms
15,920 KB
testcase_22 AC 8 ms
4,600 KB
testcase_23 AC 178 ms
19,668 KB
testcase_24 AC 31 ms
7,908 KB
testcase_25 AC 96 ms
14,800 KB
testcase_26 AC 225 ms
22,896 KB
testcase_27 AC 63 ms
11,104 KB
testcase_28 AC 324 ms
26,548 KB
testcase_29 AC 230 ms
22,220 KB
testcase_30 AC 49 ms
7,728 KB
testcase_31 TLE -
testcase_32 AC 1,376 ms
29,952 KB
testcase_33 AC 505 ms
21,128 KB
testcase_34 AC 824 ms
26,216 KB
testcase_35 AC 517 ms
23,484 KB
testcase_36 AC 49 ms
7,764 KB
testcase_37 AC 78 ms
10,056 KB
testcase_38 AC 1,917 ms
31,860 KB
testcase_39 AC 205 ms
15,124 KB
testcase_40 AC 229 ms
15,460 KB
testcase_41 AC 1,040 ms
29,500 KB
testcase_42 AC 308 ms
18,516 KB
testcase_43 AC 325 ms
20,868 KB
testcase_44 AC 297 ms
19,000 KB
testcase_45 AC 184 ms
16,660 KB
testcase_46 AC 60 ms
8,856 KB
testcase_47 AC 29 ms
6,576 KB
testcase_48 AC 1,819 ms
32,304 KB
testcase_49 AC 10 ms
4,924 KB
testcase_50 AC 1 ms
4,376 KB
testcase_51 AC 1 ms
4,376 KB
testcase_52 TLE -
testcase_53 AC 1,844 ms
45,292 KB
07_evil_01.txt AC 1,217 ms
60,624 KB
07_evil_02.txt TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <utility>
#include <atcoder/maxflow>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
#define rep(i,n) for(int i=0; i<(n); i++)


int N;
vector<int> A,B;
vector<int> AI,BI;


int main(){
  cin >> N;
  A.resize(N);
  B.resize(N);
  rep(i,N){ cin >> A[i] >> B[i]; A[i]--; B[i]--; }
  AI.resize(N);
  BI.resize(N);

  atcoder::mf_graph<int> G(N*2+2);
  rep(i,N){
    G.add_edge(N*2,i,1);
    AI[i] = G.add_edge(i,N+A[i],1);
    BI[i] = G.add_edge(i,N+B[i],1);
    G.add_edge(N+i,N*2+1,1);
  }
  int f = G.flow(N*2,N*2+1);

  if(f != N){ cout << "No\n"; return 0; }

  cout << "Yes\n";

  rep(i,N){
    auto eA = G.get_edge(AI[i]);
    if(eA.flow == 1) cout << (A[i]+1) << "\n";
    else cout << (B[i]+1) << "\n";
  }
  return 0;
}




struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_instance;




0