結果

問題 No.2061 XOR Sort
ユーザー ぷらぷら
提出日時 2022-08-26 21:55:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 545 ms / 2,000 ms
コード長 1,234 bytes
コンパイル時間 2,691 ms
コンパイル使用メモリ 205,100 KB
実行使用メモリ 43,300 KB
最終ジャッジ日時 2024-04-21 23:58:31
合計ジャッジ時間 8,945 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 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 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 267 ms
22,664 KB
testcase_15 AC 258 ms
21,388 KB
testcase_16 AC 517 ms
42,160 KB
testcase_17 AC 337 ms
27,276 KB
testcase_18 AC 339 ms
27,520 KB
testcase_19 AC 337 ms
27,536 KB
testcase_20 AC 55 ms
7,320 KB
testcase_21 AC 150 ms
13,892 KB
testcase_22 AC 270 ms
21,764 KB
testcase_23 AC 7 ms
5,376 KB
testcase_24 AC 531 ms
43,036 KB
testcase_25 AC 532 ms
43,140 KB
testcase_26 AC 533 ms
43,300 KB
testcase_27 AC 533 ms
43,252 KB
testcase_28 AC 545 ms
39,592 KB
testcase_29 AC 59 ms
12,512 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 8 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 1 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 1 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 1 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 1 ms
5,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