結果

問題 No.911 ラッキーソート
ユーザー vwxyzvwxyz
提出日時 2021-10-14 23:54:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 275 ms / 2,000 ms
コード長 805 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 11,860 KB
実行使用メモリ 38,276 KB
最終ジャッジ日時 2023-10-17 19:27:22
合計ジャッジ時間 8,457 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
9,996 KB
testcase_01 AC 29 ms
9,996 KB
testcase_02 AC 29 ms
9,996 KB
testcase_03 AC 30 ms
10,064 KB
testcase_04 AC 29 ms
10,064 KB
testcase_05 AC 29 ms
10,064 KB
testcase_06 AC 29 ms
10,064 KB
testcase_07 AC 29 ms
10,064 KB
testcase_08 AC 29 ms
10,064 KB
testcase_09 AC 29 ms
10,064 KB
testcase_10 AC 29 ms
10,060 KB
testcase_11 AC 30 ms
10,064 KB
testcase_12 AC 29 ms
10,064 KB
testcase_13 AC 250 ms
35,728 KB
testcase_14 AC 261 ms
36,052 KB
testcase_15 AC 250 ms
35,000 KB
testcase_16 AC 264 ms
38,272 KB
testcase_17 AC 275 ms
37,376 KB
testcase_18 AC 271 ms
37,368 KB
testcase_19 AC 255 ms
37,100 KB
testcase_20 AC 262 ms
35,168 KB
testcase_21 AC 266 ms
37,036 KB
testcase_22 AC 257 ms
35,132 KB
testcase_23 AC 239 ms
32,960 KB
testcase_24 AC 233 ms
31,472 KB
testcase_25 AC 153 ms
22,764 KB
testcase_26 AC 123 ms
20,168 KB
testcase_27 AC 72 ms
14,904 KB
testcase_28 AC 53 ms
12,436 KB
testcase_29 AC 35 ms
10,728 KB
testcase_30 AC 30 ms
10,180 KB
testcase_31 AC 29 ms
10,008 KB
testcase_32 AC 29 ms
10,064 KB
testcase_33 AC 30 ms
10,068 KB
testcase_34 AC 29 ms
10,060 KB
testcase_35 AC 29 ms
10,064 KB
testcase_36 AC 28 ms
10,000 KB
testcase_37 AC 29 ms
10,064 KB
testcase_38 AC 250 ms
38,276 KB
testcase_39 AC 261 ms
36,524 KB
testcase_40 AC 35 ms
10,716 KB
testcase_41 AC 264 ms
35,940 KB
testcase_42 AC 188 ms
25,960 KB
testcase_43 AC 259 ms
36,324 KB
testcase_44 AC 126 ms
35,724 KB
testcase_45 AC 155 ms
37,408 KB
testcase_46 AC 126 ms
36,804 KB
testcase_47 AC 142 ms
35,204 KB
testcase_48 AC 133 ms
36,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline

N,L,R=map(int,readline().split())
A=list(map(int,readline().split()))
bit_lst=[None for bit in range(62)]
for i in range(1,N):
    bit=(A[i-1]^A[i]).bit_length()-1
    if A[i-1]>>bit&1 and not A[i]>>bit&1:
        if bit_lst[bit]==0:
            print(0)
            exit()
        bit_lst[bit]=1
    elif not A[i-1]>>bit&1 and A[i]>>bit&1:
        if bit_lst[bit]==1:
            print(0)
            exit()
        bit_lst[bit]=0
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