結果

問題 No.2061 XOR Sort
ユーザー ぷらぷら
提出日時 2022-08-26 21:55:20
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 599 ms / 2,000 ms
コード長 1,234 bytes
コンパイル時間 2,381 ms
コンパイル使用メモリ 209,868 KB
実行使用メモリ 42,988 KB
最終ジャッジ日時 2023-08-04 01:24:33
合計ジャッジ時間 10,837 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 303 ms
22,652 KB
testcase_15 AC 296 ms
21,360 KB
testcase_16 AC 583 ms
42,008 KB
testcase_17 AC 382 ms
27,152 KB
testcase_18 AC 390 ms
27,456 KB
testcase_19 AC 382 ms
27,312 KB
testcase_20 AC 61 ms
7,232 KB
testcase_21 AC 169 ms
13,776 KB
testcase_22 AC 308 ms
21,736 KB
testcase_23 AC 8 ms
4,376 KB
testcase_24 AC 599 ms
42,988 KB
testcase_25 AC 599 ms
42,896 KB
testcase_26 AC 597 ms
42,928 KB
testcase_27 AC 595 ms
42,824 KB
testcase_28 AC 593 ms
39,548 KB
testcase_29 AC 64 ms
12,240 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 8 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

constexpr int mod = 998244353;

long long modpow(long long a,long long b) {
    long long ans = 1;
    while(b) {
        if(b & 1) {
            (ans *= a) %= mod;
        }
        (a *= a) %= mod;
        b /= 2;
    }
    return ans;
}

int main() {
    int N;
    cin >> N;
    vector<int>A(N);
    vector<vector<int>>B;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    B.push_back(A);
    int cnt = 0;
    for(int i = 29; i >= 0; i--) {
        vector<vector<int>>C;
        bool flag = false;
        for(int j = 0; j < B.size(); j++) {
            vector<int>D,E;
            for(int k = 0; k < B[j].size(); k++) {
                if(1 & (B[j][k] >> i)) {
                    D.push_back(B[j][k]);
                }
                else {
                    E.push_back(B[j][k]);
                }
            }
            if(!D.empty() && !E.empty()) {
                flag = true;
            }
            if(!D.empty()) {
                C.push_back(D);
            }
            if(!E.empty()) {
                C.push_back(E);
            }
        }
        if(flag) {
            cnt++;
        }
        B = C;
    }
    cout << modpow(2,cnt) << endl;
}
0