結果

問題 No.911 ラッキーソート
ユーザー ああいいああいい
提出日時 2022-06-12 18:09:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,591 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 81,612 KB
実行使用メモリ 112,172 KB
最終ジャッジ日時 2023-10-24 12:03:43
合計ジャッジ時間 6,814 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,352 KB
testcase_01 AC 37 ms
53,352 KB
testcase_02 AC 36 ms
53,352 KB
testcase_03 WA -
testcase_04 AC 36 ms
53,352 KB
testcase_05 WA -
testcase_06 AC 35 ms
53,352 KB
testcase_07 AC 36 ms
53,352 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 35 ms
53,352 KB
testcase_11 WA -
testcase_12 AC 36 ms
53,352 KB
testcase_13 WA -
testcase_14 AC 146 ms
112,004 KB
testcase_15 AC 105 ms
105,804 KB
testcase_16 AC 167 ms
111,972 KB
testcase_17 AC 138 ms
112,080 KB
testcase_18 WA -
testcase_19 AC 134 ms
112,000 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 180 ms
110,792 KB
testcase_23 AC 116 ms
105,256 KB
testcase_24 WA -
testcase_25 AC 115 ms
94,692 KB
testcase_26 AC 87 ms
88,340 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 48 ms
66,432 KB
testcase_30 AC 44 ms
62,016 KB
testcase_31 AC 40 ms
59,512 KB
testcase_32 WA -
testcase_33 AC 37 ms
53,352 KB
testcase_34 WA -
testcase_35 AC 37 ms
53,352 KB
testcase_36 AC 36 ms
53,352 KB
testcase_37 AC 37 ms
53,352 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 49 ms
66,432 KB
testcase_41 AC 132 ms
111,248 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 115 ms
111,268 KB
testcase_45 AC 134 ms
112,036 KB
testcase_46 AC 126 ms
112,020 KB
testcase_47 AC 110 ms
105,860 KB
testcase_48 AC 129 ms
110,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,L,R = map(int,input().split())
A = list(map(int,input().split()))
C = 60
x = [-1] * C
import sys
if N == 1:
    print(R - L + 1)
    exit()
    
for i in range(N - 1):
    for j in reversed(range(C)):
        mask = 1 << j
        if A[i] & mask == A[i + 1] & mask:
            continue
        if A[i] & mask == 0:
            if x[j] == 1:
                print(0)
                exit()
            x[j] = 0
        else:
            if x[j] == 0:
                print(0)
                exit()
            x[j] = 1
        break
def calc(S):
    if S == -1:
        return 0
    dp = [0] * C
    mask = 1 << (C - 1)
    if S & mask:
        if x[-1] == 1:
            same = 1
            dp[-1] = 0
        elif x[-1] == 0:
            same = 0
            dp[-1] = 1
        else:
            same = 1
            dp[-1] = 1
    else:
        if x[-1] == 1:
            return 0
        elif x[-1] == 0:
            same = 1
            dp[-1] = 0
        else:
            same = 1
            dp[-1] = 0
            
    for j in reversed(range(C - 1)):
        mask = 1 << j
        if S & mask:
            if x[j] == 1:
                dp[j] = dp[j+1]
            elif x[j] == 0:
                dp[j] = dp[j+1] + same
                same = 0
            else:
                dp[j] = dp[j+1] * 2 + same
        else:
            if x[j] == 1:
                dp[j] = dp[j+1]
                same = 0
            elif x[j] == 0:
                dp[j] = dp[j+1]
            else:
                dp[j] = dp[j+1] * 2
    return dp[0] + same
print(calc(R) - calc(L -1))
        
0