結果

問題 No.1640 簡単な色塗り
ユーザー trineutrontrineutron
提出日時 2021-08-06 23:47:11
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 793 bytes
コンパイル時間 33,754 ms
コンパイル使用メモリ 134,924 KB
実行使用メモリ 50,348 KB
最終ジャッジ日時 2023-09-12 03:27:51
合計ジャッジ時間 18,045 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 133 ms
35,428 KB
testcase_05 AC 136 ms
35,588 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 250 ms
21,264 KB
testcase_11 AC 180 ms
18,756 KB
testcase_12 AC 147 ms
17,196 KB
testcase_13 AC 512 ms
32,304 KB
testcase_14 AC 492 ms
33,116 KB
testcase_15 AC 95 ms
12,628 KB
testcase_16 AC 129 ms
16,492 KB
testcase_17 AC 426 ms
35,468 KB
testcase_18 AC 14 ms
5,432 KB
testcase_19 AC 155 ms
17,328 KB
testcase_20 AC 249 ms
20,860 KB
testcase_21 AC 182 ms
18,948 KB
testcase_22 AC 10 ms
4,920 KB
testcase_23 AC 291 ms
21,828 KB
testcase_24 AC 45 ms
10,416 KB
testcase_25 AC 158 ms
17,580 KB
testcase_26 AC 334 ms
32,384 KB
testcase_27 AC 89 ms
12,112 KB
testcase_28 AC 503 ms
31,484 KB
testcase_29 AC 365 ms
32,788 KB
testcase_30 AC 55 ms
7,660 KB
testcase_31 AC 2,427 ms
36,248 KB
testcase_32 AC 2,087 ms
29,420 KB
testcase_33 AC 1,013 ms
20,352 KB
testcase_34 AC 1,338 ms
25,692 KB
testcase_35 AC 955 ms
22,100 KB
testcase_36 AC 56 ms
7,692 KB
testcase_37 AC 99 ms
9,500 KB
testcase_38 AC 2,388 ms
30,536 KB
testcase_39 AC 300 ms
14,632 KB
testcase_40 AC 375 ms
14,900 KB
testcase_41 AC 1,339 ms
27,444 KB
testcase_42 AC 486 ms
17,512 KB
testcase_43 AC 532 ms
19,492 KB
testcase_44 AC 481 ms
18,032 KB
testcase_45 AC 248 ms
15,504 KB
testcase_46 AC 72 ms
8,868 KB
testcase_47 AC 35 ms
6,400 KB
testcase_48 AC 2,566 ms
31,072 KB
testcase_49 AC 11 ms
4,620 KB
testcase_50 AC 1 ms
4,380 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 AC 2,609 ms
40,176 KB
testcase_53 RE -
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);
        flow.add_edge(i, a.at(i) + n, 1);
        flow.add_edge(i, b.at(i) + n, 1);
        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