結果

問題 No.1900 Don't be Powers of 2
ユーザー 👑 colognecologne
提出日時 2022-04-08 22:04:47
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 825 bytes
コンパイル時間 2,780 ms
コンパイル使用メモリ 256,700 KB
実行使用メモリ 35,388 KB
最終ジャッジ日時 2023-08-19 00:39:08
合計ジャッジ時間 5,298 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 4 ms
4,384 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 4 ms
4,384 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 3 ms
4,384 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 4 ms
4,376 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 5 ms
4,380 KB
testcase_24 AC 6 ms
4,376 KB
testcase_25 AC 5 ms
4,376 KB
testcase_26 AC 56 ms
35,336 KB
testcase_27 AC 13 ms
8,584 KB
testcase_28 AC 5 ms
4,376 KB
testcase_29 AC 4 ms
4,376 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 51 ms
35,244 KB
testcase_34 AC 47 ms
35,316 KB
testcase_35 AC 50 ms
35,388 KB
testcase_36 AC 48 ms
34,444 KB
testcase_37 AC 4 ms
4,376 KB
testcase_38 AC 15 ms
13,360 KB
testcase_39 AC 7 ms
6,512 KB
testcase_40 AC 3 ms
4,376 KB
testcase_41 AC 5 ms
4,384 KB
testcase_42 AC 2 ms
4,500 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/maxflow>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int &a : A)
        cin >> a;

    atcoder::mf_graph<int> G(N + 2);
    vector<bool> dir(N);
    for (int i = 0; i < N; i++)
    {
        if (popcount((unsigned)A[i]) & 1)
            dir[i] = 1, G.add_edge(N, i, 1);
        else
            G.add_edge(i, N + 1, 1);
    }
    for (int i = 0; i < N; i++)
        for (int j = 0; j < i; j++)
        {
            int k = A[j] ^ A[i];
            if (k == (k & (-k)) && k != 0)
            {
                assert(dir[i] != dir[j]);
                if (dir[i])
                    G.add_edge(i, j, 1);
                else
                    G.add_edge(j, i, 1);
            }
        }
    cout << N - G.flow(N, N + 1) << endl;
}
0