結果
問題 | No.2286 Join Hands |
ユーザー |
![]() |
提出日時 | 2023-04-28 21:59:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 952 ms / 2,000 ms |
コード長 | 773 bytes |
コンパイル時間 | 4,696 ms |
コンパイル使用メモリ | 266,608 KB |
最終ジャッジ日時 | 2025-02-12 15:10:26 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 58 |
ソースコード
#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 4000000000000000001int 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;}