結果
| 問題 |
No.1640 簡単な色塗り
|
| コンテスト | |
| ユーザー |
trineutron
|
| 提出日時 | 2021-08-06 23:43:48 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 821 bytes |
| コンパイル時間 | 3,368 ms |
| コンパイル使用メモリ | 271,024 KB |
| 実行使用メモリ | 52,796 KB |
| 最終ジャッジ日時 | 2024-06-29 16:27:44 |
| 合計ジャッジ時間 | 7,528 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 1 TLE * 1 -- * 51 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/mincostflow>
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)--;
}
mcf_graph<int, int> flow(2 * n + 2);
for (int i = 0; i < n; i++)
{
flow.add_edge(2 * n, i, 1, 0);
flow.add_edge(i, a.at(i) + n, 1, 0);
flow.add_edge(i, b.at(i) + n, 1, 0);
flow.add_edge(i + n, 2 * n + 1, 1, 0);
}
if (flow.flow(2 * n, 2 * n + 1).first < 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;
}
trineutron