結果
問題 | No.1565 Union |
ユーザー |
![]() |
提出日時 | 2021-06-26 13:04:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 428 ms / 2,000 ms |
コード長 | 489 bytes |
コンパイル時間 | 7,188 ms |
コンパイル使用メモリ | 264,520 KB |
最終ジャッジ日時 | 2025-01-22 13:07:05 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#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 1000000001int main(){int n,m;cin>>n>>m;mcf_graph<int,int> G(n);rep(i,m){int a,b;cin>>a>>b;a--;b--;G.add_edge(a,b,1,1);G.add_edge(b,a,1,1);}auto ret = G.flow(0,n-1,1);if(ret.first==0)cout<<-1<<endl;else cout<<ret.second<<endl;return 0;}