結果

問題 No.1640 簡単な色塗り
ユーザー trineutrontrineutron
提出日時 2021-08-07 00:12:57
言語 C++23(draft)
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 881 bytes
コンパイル時間 3,623 ms
コンパイル使用メモリ 259,752 KB
実行使用メモリ 55,748 KB
最終ジャッジ日時 2023-09-12 03:37:17
合計ジャッジ時間 34,836 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 128 ms
41,128 KB
testcase_05 AC 128 ms
39,136 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 190 ms
22,104 KB
testcase_11 AC 149 ms
21,204 KB
testcase_12 AC 123 ms
19,920 KB
testcase_13 AC 368 ms
37,296 KB
testcase_14 AC 364 ms
37,652 KB
testcase_15 AC 77 ms
12,680 KB
testcase_16 AC 100 ms
19,428 KB
testcase_17 AC 280 ms
33,728 KB
testcase_18 AC 14 ms
5,332 KB
testcase_19 AC 120 ms
19,508 KB
testcase_20 AC 200 ms
21,148 KB
testcase_21 AC 137 ms
20,436 KB
testcase_22 AC 9 ms
4,796 KB
testcase_23 AC 211 ms
22,428 KB
testcase_24 AC 41 ms
10,368 KB
testcase_25 AC 117 ms
19,988 KB
testcase_26 AC 254 ms
32,256 KB
testcase_27 AC 72 ms
12,404 KB
testcase_28 AC 349 ms
38,164 KB
testcase_29 AC 233 ms
32,372 KB
testcase_30 AC 51 ms
7,676 KB
testcase_31 TLE -
testcase_32 AC 1,919 ms
29,988 KB
testcase_33 AC 802 ms
20,768 KB
testcase_34 AC 1,060 ms
26,368 KB
testcase_35 AC 717 ms
22,752 KB
testcase_36 AC 50 ms
8,032 KB
testcase_37 AC 82 ms
9,800 KB
testcase_38 TLE -
testcase_39 AC 250 ms
15,048 KB
testcase_40 AC 270 ms
15,436 KB
testcase_41 AC 1,377 ms
27,260 KB
testcase_42 AC 342 ms
18,328 KB
testcase_43 AC 288 ms
20,632 KB
testcase_44 AC 339 ms
18,956 KB
testcase_45 AC 192 ms
16,164 KB
testcase_46 AC 63 ms
8,824 KB
testcase_47 AC 32 ms
6,352 KB
testcase_48 AC 1,902 ms
31,292 KB
testcase_49 AC 10 ms
4,704 KB
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 1 ms
4,376 KB
testcase_52 TLE -
testcase_53 TLE -
07_evil_01.txt -- -
07_evil_02.txt -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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, a.at(i) + n, 1);
        flow.add_edge(i, b.at(i) + n, 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 + 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 << '\n';
        }
    }
    return 0;
}
0