結果

問題 No.911 ラッキーソート
ユーザー vwxyzvwxyz
提出日時 2021-10-14 23:37:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 1,042 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 81,872 KB
実行使用メモリ 111,880 KB
最終ジャッジ日時 2023-10-17 19:26:23
合計ジャッジ時間 7,485 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,300 KB
testcase_01 AC 37 ms
53,300 KB
testcase_02 AC 37 ms
53,300 KB
testcase_03 AC 42 ms
59,240 KB
testcase_04 AC 40 ms
58,984 KB
testcase_05 AC 41 ms
59,240 KB
testcase_06 AC 37 ms
53,300 KB
testcase_07 AC 38 ms
53,300 KB
testcase_08 AC 38 ms
53,300 KB
testcase_09 AC 42 ms
59,240 KB
testcase_10 AC 41 ms
59,048 KB
testcase_11 AC 38 ms
53,300 KB
testcase_12 AC 38 ms
53,300 KB
testcase_13 AC 201 ms
105,840 KB
testcase_14 AC 171 ms
111,164 KB
testcase_15 AC 161 ms
105,724 KB
testcase_16 AC 186 ms
111,788 KB
testcase_17 AC 182 ms
111,780 KB
testcase_18 AC 183 ms
111,880 KB
testcase_19 AC 178 ms
111,148 KB
testcase_20 AC 183 ms
105,784 KB
testcase_21 AC 194 ms
110,904 KB
testcase_22 AC 191 ms
109,904 KB
testcase_23 AC 177 ms
101,868 KB
testcase_24 AC 171 ms
97,592 KB
testcase_25 AC 122 ms
92,692 KB
testcase_26 AC 110 ms
86,712 KB
testcase_27 AC 77 ms
76,956 KB
testcase_28 AC 62 ms
69,308 KB
testcase_29 AC 51 ms
64,200 KB
testcase_30 AC 51 ms
62,072 KB
testcase_31 AC 43 ms
59,372 KB
testcase_32 AC 37 ms
53,332 KB
testcase_33 AC 44 ms
60,028 KB
testcase_34 AC 39 ms
59,020 KB
testcase_35 AC 41 ms
59,356 KB
testcase_36 AC 37 ms
53,332 KB
testcase_37 AC 41 ms
59,356 KB
testcase_38 AC 183 ms
111,788 KB
testcase_39 AC 197 ms
106,308 KB
testcase_40 AC 50 ms
64,200 KB
testcase_41 AC 178 ms
111,072 KB
testcase_42 AC 135 ms
97,296 KB
testcase_43 AC 176 ms
111,188 KB
testcase_44 AC 203 ms
105,852 KB
testcase_45 AC 178 ms
111,188 KB
testcase_46 AC 178 ms
111,840 KB
testcase_47 AC 158 ms
105,704 KB
testcase_48 AC 182 ms
109,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline

N,L,R=map(int,readline().split())
A=list(map(int,readline().split()))
bit_lst=[set() for bit in range(62)]
for i in range(1,N):
    for bit in range(60,-1,-1):
        if A[i-1]>>bit&1 and not A[i]>>bit&1:
            bit_lst[bit].add(1)
            break
        elif not A[i-1]>>bit&1 and A[i]>>bit&1:
            bit_lst[bit].add(0)
            break
for bit in range(62):
    if len(bit_lst[bit])>=2:
        ans=0
        break
else:
    for bit in range(62):
        if bit_lst[bit]=={0}:
            bit_lst[bit]=0
        elif bit_lst[bit]=={1}:
            bit_lst[bit]=1
        else:
            bit_lst[bit]=None
    def cnt(N):
        retu=0
        for bit in range(62):
            if N>>bit&1 and bit_lst[bit]!=1:
                for i in range(bit+1,62):
                    if bit_lst[i]!=None and bit_lst[i]!=N>>i&1:
                        break
                else:
                    retu+=pow(2,bit_lst[:bit].count(None))
        return retu
    ans=cnt(R+1)-cnt(L)
print(ans)
0