結果

問題 No.1640 簡単な色塗り
ユーザー trineutrontrineutron
提出日時 2021-08-07 00:06:03
言語 C++23(draft)
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 881 bytes
コンパイル時間 3,415 ms
コンパイル使用メモリ 257,880 KB
実行使用メモリ 39,576 KB
最終ジャッジ日時 2023-09-12 03:32:59
合計ジャッジ時間 16,400 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
11,480 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 124 ms
34,920 KB
testcase_05 AC 128 ms
34,868 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 213 ms
21,988 KB
testcase_11 AC 152 ms
19,784 KB
testcase_12 AC 124 ms
20,700 KB
testcase_13 AC 406 ms
39,576 KB
testcase_14 AC 367 ms
36,792 KB
testcase_15 AC 79 ms
12,520 KB
testcase_16 AC 107 ms
19,132 KB
testcase_17 AC 298 ms
32,992 KB
testcase_18 AC 14 ms
5,300 KB
testcase_19 AC 124 ms
20,540 KB
testcase_20 AC 207 ms
22,012 KB
testcase_21 AC 144 ms
21,060 KB
testcase_22 AC 9 ms
4,812 KB
testcase_23 AC 217 ms
23,472 KB
testcase_24 AC 38 ms
10,328 KB
testcase_25 AC 127 ms
20,356 KB
testcase_26 AC 236 ms
32,736 KB
testcase_27 AC 74 ms
12,108 KB
testcase_28 AC 363 ms
36,132 KB
testcase_29 AC 244 ms
34,340 KB
testcase_30 AC 50 ms
7,664 KB
testcase_31 TLE -
testcase_32 AC 1,452 ms
30,300 KB
testcase_33 AC 752 ms
20,920 KB
testcase_34 AC 1,280 ms
26,136 KB
testcase_35 AC 678 ms
22,896 KB
testcase_36 AC 51 ms
7,608 KB
testcase_37 AC 83 ms
10,264 KB
testcase_38 AC 1,782 ms
31,636 KB
testcase_39 AC 229 ms
15,028 KB
testcase_40 AC 254 ms
15,488 KB
testcase_41 AC 1,439 ms
28,036 KB
testcase_42 AC 337 ms
18,620 KB
testcase_43 AC 356 ms
20,728 KB
testcase_44 AC 336 ms
18,980 KB
testcase_45 AC 202 ms
16,196 KB
testcase_46 AC 65 ms
9,104 KB
testcase_47 AC 33 ms
6,900 KB
testcase_48 TLE -
testcase_49 AC 10 ms
4,736 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(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);
    }
    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