結果

問題 No.1640 簡単な色塗り
ユーザー trineutrontrineutron
提出日時 2021-08-07 00:10:55
言語 C++23(draft)
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 881 bytes
コンパイル時間 3,714 ms
コンパイル使用メモリ 259,404 KB
実行使用メモリ 50,480 KB
最終ジャッジ日時 2023-09-12 03:33:44
合計ジャッジ時間 15,971 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 124 ms
36,504 KB
testcase_05 AC 122 ms
35,468 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 169 ms
21,604 KB
testcase_11 AC 136 ms
19,684 KB
testcase_12 AC 116 ms
17,956 KB
testcase_13 AC 318 ms
32,596 KB
testcase_14 AC 325 ms
32,500 KB
testcase_15 AC 74 ms
12,604 KB
testcase_16 AC 94 ms
17,140 KB
testcase_17 AC 248 ms
34,388 KB
testcase_18 AC 13 ms
5,356 KB
testcase_19 AC 112 ms
18,120 KB
testcase_20 AC 164 ms
21,584 KB
testcase_21 AC 136 ms
19,380 KB
testcase_22 AC 9 ms
4,820 KB
testcase_23 AC 195 ms
22,016 KB
testcase_24 AC 39 ms
10,396 KB
testcase_25 AC 114 ms
18,152 KB
testcase_26 AC 213 ms
33,088 KB
testcase_27 AC 71 ms
12,132 KB
testcase_28 AC 302 ms
33,532 KB
testcase_29 AC 218 ms
32,188 KB
testcase_30 AC 50 ms
7,744 KB
testcase_31 AC 1,793 ms
38,040 KB
testcase_32 AC 1,404 ms
30,036 KB
testcase_33 AC 539 ms
20,520 KB
testcase_34 AC 912 ms
25,372 KB
testcase_35 AC 408 ms
22,844 KB
testcase_36 AC 50 ms
7,836 KB
testcase_37 AC 80 ms
9,824 KB
testcase_38 AC 1,487 ms
31,396 KB
testcase_39 AC 216 ms
14,788 KB
testcase_40 AC 234 ms
15,048 KB
testcase_41 AC 969 ms
27,492 KB
testcase_42 AC 289 ms
18,320 KB
testcase_43 AC 304 ms
20,548 KB
testcase_44 AC 287 ms
18,980 KB
testcase_45 AC 182 ms
16,000 KB
testcase_46 AC 62 ms
8,736 KB
testcase_47 AC 31 ms
6,708 KB
testcase_48 AC 1,594 ms
30,784 KB
testcase_49 AC 11 ms
4,576 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 2 ms
4,500 KB
testcase_52 TLE -
testcase_53 TLE -
07_evil_01.txt AC 1,008 ms
70,828 KB
07_evil_02.txt AC 1,948 ms
127,656 KB
権限があれば一括ダウンロードができます

ソースコード

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 + n, 2 * n + 1, 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);
    }
    for (int i = 0; i < n; i++)
    {
        flow.add_edge(2 * n, i, 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