結果

問題 No.2061 XOR Sort
ユーザー みここみここ
提出日時 2022-12-13 22:35:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 353 ms / 2,000 ms
コード長 863 bytes
コンパイル時間 860 ms
コンパイル使用メモリ 78,436 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2024-04-25 06:11:46
合計ジャッジ時間 6,434 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 179 ms
5,376 KB
testcase_15 AC 175 ms
5,376 KB
testcase_16 AC 345 ms
7,256 KB
testcase_17 AC 226 ms
5,632 KB
testcase_18 AC 227 ms
6,016 KB
testcase_19 AC 225 ms
5,900 KB
testcase_20 AC 38 ms
5,376 KB
testcase_21 AC 104 ms
5,376 KB
testcase_22 AC 179 ms
5,376 KB
testcase_23 AC 6 ms
5,376 KB
testcase_24 AC 351 ms
7,288 KB
testcase_25 AC 353 ms
7,324 KB
testcase_26 AC 352 ms
7,588 KB
testcase_27 AC 350 ms
7,408 KB
testcase_28 AC 350 ms
7,472 KB
testcase_29 AC 48 ms
11,776 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 7 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

const int MOD = 998244353;

void rec(int k, vector<int> v, bool *b)
{
    if (k == -1)
    {
        return;
    }
    vector<int> x, y;
    for (int i = 0; i < (int)v.size(); i++)
    {
        if ((v[i] >> k) & 1)
        {
            x.push_back(v[i]);
        }
        else
        {
            y.push_back(v[i]);
        }
    }
    if (!x.empty() && !y.empty())
    {
        b[k] = true;
    }
    if (!x.empty())
    {
        rec(k - 1, x, b);
    }
    if (!y.empty())
    {
        rec(k - 1, y, b);
    }
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    bool b[32]{0};
    rec(29, a, b);
    int ans = 1;
    for (int i = 0; i < 30; i++)
    {
        ans <<= b[i];
    }
    cout << ans % MOD << endl;
}
0