結果

問題 No.2286 Join Hands
ユーザー 沙耶花沙耶花
提出日時 2023-04-28 21:59:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 951 ms / 2,000 ms
コード長 773 bytes
コンパイル時間 4,882 ms
コンパイル使用メモリ 276,248 KB
実行使用メモリ 6,420 KB
最終ジャッジ日時 2024-04-28 23:36:05
合計ジャッジ時間 23,358 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 105 ms
5,376 KB
testcase_09 AC 137 ms
5,376 KB
testcase_10 AC 388 ms
5,648 KB
testcase_11 AC 554 ms
5,900 KB
testcase_12 AC 547 ms
5,908 KB
testcase_13 AC 366 ms
5,520 KB
testcase_14 AC 746 ms
6,036 KB
testcase_15 AC 688 ms
6,032 KB
testcase_16 AC 754 ms
6,036 KB
testcase_17 AC 88 ms
5,376 KB
testcase_18 AC 924 ms
6,292 KB
testcase_19 AC 585 ms
5,648 KB
testcase_20 AC 773 ms
5,900 KB
testcase_21 AC 951 ms
6,284 KB
testcase_22 AC 661 ms
5,900 KB
testcase_23 AC 365 ms
5,608 KB
testcase_24 AC 868 ms
6,156 KB
testcase_25 AC 454 ms
5,652 KB
testcase_26 AC 322 ms
5,604 KB
testcase_27 AC 419 ms
5,520 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 488 ms
6,412 KB
testcase_48 AC 487 ms
6,416 KB
testcase_49 AC 719 ms
6,292 KB
testcase_50 AC 724 ms
6,416 KB
testcase_51 AC 5 ms
5,396 KB
testcase_52 AC 7 ms
5,396 KB
testcase_53 AC 486 ms
6,416 KB
testcase_54 AC 182 ms
5,648 KB
testcase_55 AC 373 ms
5,904 KB
testcase_56 AC 721 ms
6,416 KB
testcase_57 AC 715 ms
6,420 KB
testcase_58 AC 487 ms
6,412 KB
testcase_59 AC 487 ms
6,420 KB
testcase_60 AC 8 ms
6,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


int main(){
	
	int N,M;
	cin>>N>>M;
	
	mcf_graph<int,int> G(N*2+2);
	int S = N*2;
	int T = N*2+1;
	
	rep(i,N){
		G.add_edge(S,i,1,0);
		G.add_edge(S,i,1,1);
		G.add_edge(N+i,T,1,0);
		G.add_edge(N+i,T,1,1);
	}
	
	rep(i,M){
		int a,b;
		cin>>a>>b;
		a--,b--;
		G.add_edge(a,N+b,2,0);
		G.add_edge(b,N+a,2,0);
	}
	
	auto ans = G.flow(S,T);
	
	long long A = ans.first;
	A -= (N*2) - A;
	A /= 2;
	if(ans.first==N*2-2 && ans.second==ans.first)A -= 2;
	cout<<A<<endl;
	
	//cout<<ans.first<<','<<ans.second<<endl;
	
	return 0;
}
0