結果

問題 No.2061 XOR Sort
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2022-08-12 09:34:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 343 ms / 2,000 ms
コード長 590 bytes
コンパイル時間 1,931 ms
コンパイル使用メモリ 81,416 KB
実行使用メモリ 198,540 KB
最終ジャッジ日時 2023-10-23 19:48:42
合計ジャッジ時間 6,982 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,232 KB
testcase_01 AC 35 ms
53,232 KB
testcase_02 AC 35 ms
53,232 KB
testcase_03 AC 37 ms
53,232 KB
testcase_04 AC 36 ms
53,232 KB
testcase_05 AC 36 ms
53,232 KB
testcase_06 AC 37 ms
53,232 KB
testcase_07 AC 36 ms
53,232 KB
testcase_08 AC 37 ms
53,232 KB
testcase_09 AC 36 ms
53,232 KB
testcase_10 AC 36 ms
53,232 KB
testcase_11 AC 36 ms
53,232 KB
testcase_12 AC 36 ms
53,232 KB
testcase_13 AC 37 ms
53,232 KB
testcase_14 AC 209 ms
139,276 KB
testcase_15 AC 181 ms
131,252 KB
testcase_16 AC 318 ms
183,476 KB
testcase_17 AC 220 ms
146,872 KB
testcase_18 AC 221 ms
144,872 KB
testcase_19 AC 226 ms
145,288 KB
testcase_20 AC 86 ms
81,576 KB
testcase_21 AC 131 ms
108,108 KB
testcase_22 AC 182 ms
131,220 KB
testcase_23 AC 54 ms
68,444 KB
testcase_24 AC 304 ms
183,704 KB
testcase_25 AC 323 ms
185,988 KB
testcase_26 AC 338 ms
198,540 KB
testcase_27 AC 343 ms
198,244 KB
testcase_28 AC 314 ms
183,304 KB
testcase_29 AC 87 ms
85,240 KB
testcase_30 AC 36 ms
53,248 KB
testcase_31 AC 55 ms
68,444 KB
testcase_32 AC 36 ms
53,248 KB
testcase_33 AC 36 ms
53,248 KB
testcase_34 AC 36 ms
53,248 KB
testcase_35 AC 37 ms
53,248 KB
testcase_36 AC 37 ms
53,248 KB
testcase_37 AC 37 ms
53,248 KB
testcase_38 AC 36 ms
53,248 KB
testcase_39 AC 36 ms
53,248 KB
testcase_40 AC 35 ms
53,248 KB
testcase_41 AC 35 ms
53,248 KB
testcase_42 AC 37 ms
53,248 KB
testcase_43 AC 37 ms
53,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #



mod=998244353
n=int(input())
a=list(map(int,input().split()))
a.sort() #ソートしても答えは変わらない。
G=[(0,n-1)]
ans=1
for j in range(29,-1,-1):
    res=1
    newG=[]
    for l,r in G:
        if (a[l]>>j)&1==(a[r]>>j)&1:
            newG.append((l,r))
            continue
        res=2 #広義単調増加、減少が区別できる。
        mid=-1
        for i in range(l,r):
            if (a[i]>>j)&1<(a[i+1]>>j)&1:
                mid=i
                break
        newG.append((l,mid))
        newG.append((mid+1,r))
    ans*=res
    G=newG[:]
print(ans%mod)
0