結果

問題 No.1640 簡単な色塗り
ユーザー 沙耶花沙耶花
提出日時 2021-08-06 23:09:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 796 bytes
コンパイル時間 4,716 ms
コンパイル使用メモリ 267,932 KB
実行使用メモリ 45,064 KB
最終ジャッジ日時 2023-09-12 03:10:59
合計ジャッジ時間 17,739 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,500 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 88 ms
31,488 KB
testcase_05 AC 88 ms
30,784 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 149 ms
19,248 KB
testcase_11 AC 124 ms
16,484 KB
testcase_12 AC 99 ms
14,968 KB
testcase_13 AC 282 ms
28,568 KB
testcase_14 AC 329 ms
29,100 KB
testcase_15 AC 65 ms
11,580 KB
testcase_16 AC 86 ms
13,920 KB
testcase_17 AC 263 ms
24,704 KB
testcase_18 AC 11 ms
5,208 KB
testcase_19 AC 107 ms
14,932 KB
testcase_20 AC 155 ms
18,740 KB
testcase_21 AC 116 ms
16,108 KB
testcase_22 AC 7 ms
4,624 KB
testcase_23 AC 178 ms
19,952 KB
testcase_24 AC 32 ms
8,068 KB
testcase_25 AC 106 ms
15,068 KB
testcase_26 AC 214 ms
23,888 KB
testcase_27 AC 62 ms
11,256 KB
testcase_28 AC 319 ms
27,248 KB
testcase_29 AC 194 ms
23,516 KB
testcase_30 AC 46 ms
7,908 KB
testcase_31 TLE -
testcase_32 AC 1,465 ms
30,704 KB
testcase_33 AC 619 ms
21,208 KB
testcase_34 AC 1,193 ms
27,016 KB
testcase_35 AC 717 ms
23,364 KB
testcase_36 AC 45 ms
7,776 KB
testcase_37 AC 77 ms
10,088 KB
testcase_38 AC 1,627 ms
32,560 KB
testcase_39 AC 209 ms
15,304 KB
testcase_40 AC 219 ms
15,612 KB
testcase_41 AC 900 ms
28,700 KB
testcase_42 AC 283 ms
18,548 KB
testcase_43 AC 319 ms
20,852 KB
testcase_44 AC 292 ms
19,308 KB
testcase_45 AC 177 ms
16,596 KB
testcase_46 AC 59 ms
9,092 KB
testcase_47 AC 28 ms
6,792 KB
testcase_48 AC 1,658 ms
31,660 KB
testcase_49 AC 9 ms
4,688 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 2 ms
4,376 KB
testcase_52 AC 1,863 ms
37,164 KB
testcase_53 AC 1,700 ms
45,064 KB
07_evil_01.txt AC 1,143 ms
60,388 KB
07_evil_02.txt AC 1,947 ms
90,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000000000

int main(){
	
	int N;
	cin>>N;
	
	vector<int> A(N),B(N);
	
	mf_graph<int> G(2*N+2);
	int S = N*2,T = N*2+1;
	vector<int> a(N),b(N);
	rep(i,N){
		scanf("%d %d",&A[i],&B[i]);
		A[i]--;B[i]--;
		a[i] = G.add_edge(i,N+A[i],1);
		b[i] = G.add_edge(i,N+B[i],1);
		G.add_edge(S,i,1);
		G.add_edge(N+i,T,1);
	}
	
	if(G.flow(S,T)!=N){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	
	vector<int> ans(N);
	rep(i,N){
		if(G.get_edge(a[i]).flow)ans[i] = 0;
		else ans[i] = 1;
	}
	
	rep(i,N){
		if(ans[i]==0)printf("%d\n",A[i]+1);
		else printf("%d\n",B[i]+1);
	}
	
	
	return 0;
}
0