結果

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

ソースコード

diff #

MOD = 998244353

def main():
    import sys
    input = sys.stdin.read().split()
    N = int(input[0])
    A = list(map(int, input[1:N+1]))
    
    current_groups = [A]
    ans = 1
    
    for bit in reversed(range(30)):  # from 29 down to 0
        new_groups = []
        for group in current_groups:
            mask = 1 << bit
            left = []
            right = []
            for x in group:
                if (x & mask) == 0:
                    left.append(x)
                else:
                    right.append(x)
            if len(left) > 0 and len(right) > 0:
                ans = (ans * 2) % MOD
            if left:
                new_groups.append(left)
            if right:
                new_groups.append(right)
        current_groups = new_groups
    
    print(ans % MOD)

if __name__ == "__main__":
    main()
0