結果
問題 | No.1582 Vertexes vs Edges |
ユーザー |
![]() |
提出日時 | 2021-07-02 22:46:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 120 ms / 2,000 ms |
コード長 | 590 bytes |
コンパイル時間 | 4,016 ms |
コンパイル使用メモリ | 241,924 KB |
実行使用メモリ | 18,396 KB |
最終ジャッジ日時 | 2024-06-29 12:38:28 |
合計ジャッジ時間 | 7,170 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:25:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 25 | for(auto[a,b]:v){ | ^
ソースコード
#include<bits/stdc++.h> using namespace std; #include<atcoder/all> using namespace atcoder; using mint=modint1000000007; using ll=long long; #define rep(i,N) for(int i=0;i<N;++i) ll N,a,b; int main(){ cin>>N; dsu g(N*2); vector<pair<ll,ll>> v; rep(i,N-1){ cin>>a>>b; v.emplace_back(--a,--b); g.merge(a,b+N); g.merge(b,a+N); } mf_graph<int> fg(N+2); rep(i,N)if(g.same(0,i)){ fg.add_edge(N,i,1); }else{ fg.add_edge(i,N+1,1); } for(auto[a,b]:v){ if(g.same(0,a))fg.add_edge(a,b,1); else fg.add_edge(b,a,1); } cout<<fg.flow(N,N+1)<<endl; }