結果
| 問題 |
No.2061 XOR Sort
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 21:48:18 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 750 bytes |
| コンパイル時間 | 355 ms |
| コンパイル使用メモリ | 82,284 KB |
| 実行使用メモリ | 128,616 KB |
| 最終ジャッジ日時 | 2025-04-15 21:49:49 |
| 合計ジャッジ時間 | 5,779 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 WA * 39 |
ソースコード
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)
lam6er