結果

問題 No.1640 簡単な色塗り
ユーザー 沙耶花沙耶花
提出日時 2021-08-06 22:06:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 779 bytes
コンパイル時間 4,661 ms
コンパイル使用メモリ 267,600 KB
実行使用メモリ 40,100 KB
最終ジャッジ日時 2023-09-12 02:03:48
合計ジャッジ時間 34,142 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,752 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 245 ms
30,940 KB
testcase_05 AC 245 ms
30,600 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 289 ms
19,188 KB
testcase_11 AC 220 ms
16,388 KB
testcase_12 AC 184 ms
14,992 KB
testcase_13 AC 534 ms
27,580 KB
testcase_14 AC 532 ms
28,252 KB
testcase_15 AC 121 ms
11,516 KB
testcase_16 AC 161 ms
14,056 KB
testcase_17 AC 406 ms
24,760 KB
testcase_18 AC 22 ms
5,036 KB
testcase_19 AC 182 ms
14,800 KB
testcase_20 AC 267 ms
18,676 KB
testcase_21 AC 212 ms
15,976 KB
testcase_22 AC 15 ms
4,688 KB
testcase_23 AC 302 ms
19,896 KB
testcase_24 AC 63 ms
7,984 KB
testcase_25 AC 185 ms
15,084 KB
testcase_26 AC 365 ms
22,312 KB
testcase_27 AC 113 ms
11,136 KB
testcase_28 AC 491 ms
26,568 KB
testcase_29 AC 356 ms
22,156 KB
testcase_30 AC 54 ms
7,792 KB
testcase_31 TLE -
testcase_32 AC 1,469 ms
29,896 KB
testcase_33 AC 587 ms
21,088 KB
testcase_34 AC 972 ms
27,352 KB
testcase_35 AC 558 ms
23,568 KB
testcase_36 AC 52 ms
7,844 KB
testcase_37 AC 84 ms
10,016 KB
testcase_38 AC 1,670 ms
32,056 KB
testcase_39 AC 220 ms
15,092 KB
testcase_40 AC 245 ms
15,468 KB
testcase_41 AC 1,310 ms
28,052 KB
testcase_42 AC 328 ms
18,292 KB
testcase_43 AC 364 ms
20,664 KB
testcase_44 AC 359 ms
19,216 KB
testcase_45 AC 208 ms
16,420 KB
testcase_46 AC 67 ms
8,968 KB
testcase_47 AC 34 ms
6,504 KB
testcase_48 TLE -
testcase_49 AC 11 ms
4,672 KB
testcase_50 AC 1 ms
4,380 KB
testcase_51 AC 1 ms
4,380 KB
testcase_52 TLE -
testcase_53 TLE -
07_evil_01.txt -- -
07_evil_02.txt -- -
権限があれば一括ダウンロードができます

ソースコード

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){
		cin>>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)cout<<A[i]+1<<endl;
		else cout<<B[i]+1<<endl;
	}
	
	
	return 0;
}
0