結果

問題 No.911 ラッキーソート
ユーザー titiatitia
提出日時 2019-12-01 04:50:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,167 bytes
コンパイル時間 81 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 49,368 KB
最終ジャッジ日時 2024-05-01 03:41:41
合計ジャッジ時間 5,053 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
17,696 KB
testcase_01 AC 26 ms
10,880 KB
testcase_02 AC 29 ms
10,752 KB
testcase_03 AC 30 ms
10,880 KB
testcase_04 AC 28 ms
10,880 KB
testcase_05 AC 27 ms
10,880 KB
testcase_06 AC 27 ms
10,880 KB
testcase_07 AC 29 ms
10,752 KB
testcase_08 AC 27 ms
10,752 KB
testcase_09 AC 28 ms
10,752 KB
testcase_10 AC 26 ms
10,752 KB
testcase_11 AC 26 ms
10,880 KB
testcase_12 AC 25 ms
10,880 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,L,R=map(int,input().split())
A=list(map(int,input().split()))

ANS=[-1]*62

for i in range(1,N):
    if A[i]==A[i-1]:
        print(0)
        sys.exit()

for i in range(61,-1,-1):
    B=[a>>i for a in A]
    C=[b^1 for b in B]

    flagb=1
    flagc=1

    for j in range(1,N):
        if B[j-1]>B[j]:
            flagb=0
        if C[j-1]>C[j]:
            flagc=0

    if flagb and flagc:
        ANS[i]=2
    elif flagb:
        ANS[i]=0
    elif flagc:
        ANS[i]=1
        A=[a^(1<<i) for a in A]
    else:
        print(0)
        sys.exit()

def calc(N,keta):
    if N<0:
        return 0
    
    if keta==-1:
        return 1

    if N & (1<<keta)==0:
        if ANS[keta]==0:
            return calc(N,keta-1)
        
        elif ANS[keta]==1:
            return 0

        elif ANS[keta]==2:
            return calc(N,keta-1)

    else:
        if ANS[keta]==0:
            return 1<<(ANS[:keta].count(2))
            
        elif ANS[keta]==1:
            return calc(N,keta-1)
        
        elif ANS[keta]==2:
            return calc(N,keta-1)+(1<<(ANS[:keta].count(2)))

print(calc(R,60)-calc(L-1,60))
0