結果

問題 No.2061 XOR Sort
ユーザー lam6er
提出日時 2025-04-15 21:49:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 750 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 81,728 KB
実行使用メモリ 128,248 KB
最終ジャッジ日時 2025-04-15 21:51:29
合計ジャッジ時間 6,223 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 WA * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

n = int(input())
a = list(map(int, input().split()))

from collections import deque

d = 0
q = deque()
q.append(a)

while q:
    current = q.popleft()
    if len(current) <= 1:
        continue
    or_val = 0
    and_val = (1 << 30) - 1  # Initialize with all bits set
    for num in current:
        or_val |= num
        and_val &= num
    mask = or_val ^ and_val
    if mask == 0:
        continue
    highest_bit = mask.bit_length() - 1
    d += 1
    group0 = []
    group1 = []
    for num in current:
        if (num >> highest_bit) & 1:
            group1.append(num)
        else:
            group0.append(num)
    if group0:
        q.append(group0)
    if group1:
        q.append(group1)

ans = pow(2, d, MOD)
print(ans)
0