結果
問題 | No.1640 簡単な色塗り |
ユーザー |
![]() |
提出日時 | 2021-08-06 23:37:03 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,542 ms / 2,000 ms |
コード長 | 793 bytes |
コンパイル時間 | 2,741 ms |
コンパイル使用メモリ | 261,460 KB |
実行使用メモリ | 49,168 KB |
最終ジャッジ日時 | 2024-06-29 16:24:49 |
合計ジャッジ時間 | 27,277 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 53 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/maxflow>using namespace std;using namespace atcoder;int main(){int n;cin >> n;vector<int> a(n), b(n);for (int i = 0; i < n; i++){cin >> a.at(i) >> b.at(i);a.at(i)--;b.at(i)--;}mf_graph<int> flow(2 * n + 2);for (int i = 0; i < n; i++){flow.add_edge(2 * n, i, 1);flow.add_edge(i, a.at(i) + n, 1);flow.add_edge(i, b.at(i) + n, 1);flow.add_edge(i + n, 2 * n + 1, 1);}if (flow.flow(2 * n, 2 * n + 1) < n){puts("No");return 0;}puts("Yes");for (auto &&e : flow.edges()){if (e.from < n and e.flow){cout << e.to - n + 1 << endl;}}return 0;}