結果
問題 | No.1640 簡単な色塗り |
ユーザー |
![]() |
提出日時 | 2021-08-07 00:09:55 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,980 ms / 2,000 ms |
コード長 | 881 bytes |
コンパイル時間 | 3,007 ms |
コンパイル使用メモリ | 260,660 KB |
実行使用メモリ | 49,336 KB |
最終ジャッジ日時 | 2024-06-29 16:31:24 |
合計ジャッジ時間 | 31,017 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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(i + n, 2 * n + 1, 1); } for (int i = 0; i < n; i++) { flow.add_edge(2 * n, i, 1); } for (int i = 0; i < n; i++) { flow.add_edge(i, a.at(i) + n, 1); flow.add_edge(i, b.at(i) + n, 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 << '\n'; } } return 0; }