結果

問題 No.911 ラッキーソート
ユーザー mkawa2mkawa2
提出日時 2019-11-02 23:58:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,690 ms / 2,000 ms
コード長 1,326 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 10,968 KB
実行使用メモリ 36,452 KB
最終ジャッジ日時 2023-10-13 01:42:55
合計ジャッジ時間 29,398 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,352 KB
testcase_01 AC 16 ms
8,300 KB
testcase_02 AC 16 ms
8,336 KB
testcase_03 AC 17 ms
8,312 KB
testcase_04 AC 16 ms
8,412 KB
testcase_05 AC 17 ms
8,248 KB
testcase_06 AC 17 ms
8,208 KB
testcase_07 AC 16 ms
8,316 KB
testcase_08 AC 16 ms
8,356 KB
testcase_09 AC 16 ms
8,220 KB
testcase_10 AC 16 ms
8,228 KB
testcase_11 AC 16 ms
8,256 KB
testcase_12 AC 16 ms
8,176 KB
testcase_13 AC 1,065 ms
33,908 KB
testcase_14 AC 1,105 ms
35,092 KB
testcase_15 AC 1,166 ms
33,312 KB
testcase_16 AC 1,245 ms
36,452 KB
testcase_17 AC 1,179 ms
35,744 KB
testcase_18 AC 1,235 ms
36,292 KB
testcase_19 AC 1,188 ms
35,468 KB
testcase_20 AC 1,329 ms
33,420 KB
testcase_21 AC 1,602 ms
35,408 KB
testcase_22 AC 1,690 ms
33,504 KB
testcase_23 AC 1,573 ms
31,204 KB
testcase_24 AC 1,459 ms
29,828 KB
testcase_25 AC 1,014 ms
20,948 KB
testcase_26 AC 673 ms
18,432 KB
testcase_27 AC 400 ms
13,156 KB
testcase_28 AC 215 ms
10,816 KB
testcase_29 AC 51 ms
9,092 KB
testcase_30 AC 24 ms
8,416 KB
testcase_31 AC 17 ms
8,244 KB
testcase_32 AC 16 ms
8,312 KB
testcase_33 AC 16 ms
8,236 KB
testcase_34 AC 16 ms
8,228 KB
testcase_35 AC 16 ms
8,212 KB
testcase_36 AC 17 ms
8,244 KB
testcase_37 AC 16 ms
8,356 KB
testcase_38 AC 1,118 ms
36,452 KB
testcase_39 AC 1,633 ms
34,104 KB
testcase_40 AC 53 ms
9,032 KB
testcase_41 AC 1,300 ms
34,352 KB
testcase_42 AC 997 ms
24,316 KB
testcase_43 AC 1,132 ms
34,696 KB
testcase_44 AC 249 ms
33,284 KB
testcase_45 AC 421 ms
34,828 KB
testcase_46 AC 214 ms
35,044 KB
testcase_47 AC 323 ms
33,628 KB
testcase_48 AC 353 ms
33,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    def bitdp(lr):
        if lr == -1: return 0
        dp = [[0] * 2 for _ in range(max_k + 1)]
        dp[0][0] = 1
        for i in range(max_k):
            lri = (lr >> (max_k - 1 - i)) & 1
            for f in range(2):
                pre = dp[i][f]
                if pre == 0: continue
                nf = f
                if dig[i] < 1 and (f == 1 or lri == 1):
                    dp[i + 1][nf] += pre
                if dig[i] > -1:
                    if lri == 1: nf = 1
                    dp[i + 1][nf] += pre
        # p2D(dp)
        return sum(dp[max_k])

    max_k = 61
    n, l, r = map(int, input().split())
    aa = list(map(int, input().split()))
    # p2D(aa)
    dig = [0] * max_k  # 1昇順 -1降順 0どちらでも
    for a0, a1 in zip(aa, aa[1:]):
        for i in range(max_k):
            a0k = (a0 >> (max_k - 1 - i)) & 1
            a1k = (a1 >> (max_k - 1 - i)) & 1
            if a0k != a1k:
                if dig[i] == a0k - a1k:
                    print(0)
                    exit()
                else:
                    dig[i] = a1k - a0k
                    break
    # print(dig)
    print(bitdp(r) - bitdp(l - 1))

main()
0