結果

問題 No.1900 Don't be Powers of 2
ユーザー 👑 colognecologne
提出日時 2022-04-08 22:00:41
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 883 bytes
コンパイル時間 3,832 ms
コンパイル使用メモリ 256,228 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-05-06 07:34:06
合計ジャッジ時間 5,219 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 5 ms
5,376 KB
testcase_04 AC 6 ms
5,376 KB
testcase_05 AC 6 ms
5,376 KB
testcase_06 AC 6 ms
5,376 KB
testcase_07 AC 5 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 5 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 5 ms
5,376 KB
testcase_18 AC 5 ms
5,376 KB
testcase_19 AC 6 ms
5,376 KB
testcase_20 AC 4 ms
5,376 KB
testcase_21 AC 4 ms
5,376 KB
testcase_22 AC 5 ms
5,376 KB
testcase_23 AC 6 ms
5,376 KB
testcase_24 AC 24 ms
5,376 KB
testcase_25 AC 24 ms
5,376 KB
testcase_26 AC 33 ms
11,648 KB
testcase_27 AC 12 ms
5,376 KB
testcase_28 AC 6 ms
5,376 KB
testcase_29 AC 6 ms
5,376 KB
testcase_30 WA -
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 27 ms
11,520 KB
testcase_34 AC 27 ms
11,520 KB
testcase_35 AC 37 ms
11,648 KB
testcase_36 AC 39 ms
11,520 KB
testcase_37 AC 6 ms
5,376 KB
testcase_38 AC 9 ms
6,272 KB
testcase_39 AC 6 ms
5,376 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int &a : A)
        cin >> a;
    vector<vector<int>> V(N);
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
        {
            int k = A[j] ^ A[i];
            if (k == (k & (-k)) && k != 0)
                V[i].push_back(j);
        }
    vector<bool> vis(N);

    int c1 = 0, c2 = 0, ans = 0;
    function<void(int, bool)> dfs = [&](int x, bool p)
    {
        if (vis[x])
            return;
        vis[x] = 1;
        if (p)
            ++c1;
        else
            ++c2;
        for (auto y : V[x])
            dfs(y, !p);
    };

    for (int i = 0; i < N; i++)
        if (!vis[i])
        {
            dfs(i, 0);
            ans += max(c1, c2);
            c1 = c2 = 0;
        }

    cout << ans << endl;
}
0