結果

問題 No.2061 XOR Sort
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2022-08-21 23:04:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 361 ms / 2,000 ms
コード長 587 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 82,400 KB
実行使用メモリ 199,160 KB
最終ジャッジ日時 2024-04-18 13:13:59
合計ジャッジ時間 6,604 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
51,968 KB
testcase_01 AC 41 ms
51,840 KB
testcase_02 AC 41 ms
52,096 KB
testcase_03 AC 41 ms
52,608 KB
testcase_04 AC 41 ms
52,224 KB
testcase_05 AC 41 ms
52,224 KB
testcase_06 AC 42 ms
52,096 KB
testcase_07 AC 42 ms
51,584 KB
testcase_08 AC 41 ms
52,096 KB
testcase_09 AC 42 ms
52,608 KB
testcase_10 AC 42 ms
52,480 KB
testcase_11 AC 41 ms
51,584 KB
testcase_12 AC 42 ms
52,352 KB
testcase_13 AC 40 ms
51,584 KB
testcase_14 AC 220 ms
138,796 KB
testcase_15 AC 198 ms
131,672 KB
testcase_16 AC 334 ms
182,836 KB
testcase_17 AC 238 ms
147,496 KB
testcase_18 AC 243 ms
145,612 KB
testcase_19 AC 243 ms
145,380 KB
testcase_20 AC 99 ms
82,048 KB
testcase_21 AC 146 ms
108,584 KB
testcase_22 AC 201 ms
131,636 KB
testcase_23 AC 65 ms
67,712 KB
testcase_24 AC 328 ms
184,164 KB
testcase_25 AC 339 ms
186,616 KB
testcase_26 AC 361 ms
199,160 KB
testcase_27 AC 356 ms
198,516 KB
testcase_28 AC 334 ms
183,296 KB
testcase_29 AC 101 ms
86,016 KB
testcase_30 AC 40 ms
51,584 KB
testcase_31 AC 69 ms
68,096 KB
testcase_32 AC 40 ms
51,968 KB
testcase_33 AC 40 ms
51,968 KB
testcase_34 AC 40 ms
52,096 KB
testcase_35 AC 41 ms
51,968 KB
testcase_36 AC 40 ms
51,968 KB
testcase_37 AC 40 ms
52,096 KB
testcase_38 AC 41 ms
51,968 KB
testcase_39 AC 40 ms
51,968 KB
testcase_40 AC 41 ms
51,712 KB
testcase_41 AC 40 ms
51,840 KB
testcase_42 AC 41 ms
52,096 KB
testcase_43 AC 41 ms
51,968 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