結果

問題 No.911 ラッキーソート
ユーザー mkawa2mkawa2
提出日時 2019-11-02 23:59:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 219 ms / 2,000 ms
コード長 1,326 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 86,916 KB
実行使用メモリ 117,256 KB
最終ジャッジ日時 2023-10-13 01:43:16
合計ジャッジ時間 8,676 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,024 KB
testcase_01 AC 69 ms
71,312 KB
testcase_02 AC 70 ms
70,912 KB
testcase_03 AC 72 ms
71,232 KB
testcase_04 AC 71 ms
71,312 KB
testcase_05 AC 71 ms
71,392 KB
testcase_06 AC 72 ms
71,312 KB
testcase_07 AC 72 ms
71,416 KB
testcase_08 AC 70 ms
71,120 KB
testcase_09 AC 72 ms
71,232 KB
testcase_10 AC 71 ms
70,904 KB
testcase_11 AC 70 ms
71,080 KB
testcase_12 AC 72 ms
71,232 KB
testcase_13 AC 219 ms
115,908 KB
testcase_14 AC 170 ms
116,884 KB
testcase_15 AC 163 ms
115,636 KB
testcase_16 AC 179 ms
117,256 KB
testcase_17 AC 178 ms
117,216 KB
testcase_18 AC 177 ms
116,840 KB
testcase_19 AC 171 ms
116,768 KB
testcase_20 AC 168 ms
116,084 KB
testcase_21 AC 179 ms
115,788 KB
testcase_22 AC 177 ms
115,232 KB
testcase_23 AC 166 ms
109,808 KB
testcase_24 AC 159 ms
104,668 KB
testcase_25 AC 124 ms
94,880 KB
testcase_26 AC 116 ms
90,584 KB
testcase_27 AC 95 ms
81,268 KB
testcase_28 AC 85 ms
77,784 KB
testcase_29 AC 80 ms
76,584 KB
testcase_30 AC 77 ms
76,196 KB
testcase_31 AC 76 ms
75,308 KB
testcase_32 AC 74 ms
71,168 KB
testcase_33 AC 77 ms
76,420 KB
testcase_34 AC 71 ms
71,172 KB
testcase_35 AC 76 ms
75,260 KB
testcase_36 AC 72 ms
71,340 KB
testcase_37 AC 74 ms
75,352 KB
testcase_38 AC 184 ms
116,864 KB
testcase_39 AC 184 ms
111,904 KB
testcase_40 AC 82 ms
76,116 KB
testcase_41 AC 174 ms
116,244 KB
testcase_42 AC 134 ms
93,460 KB
testcase_43 AC 169 ms
116,468 KB
testcase_44 AC 146 ms
116,428 KB
testcase_45 AC 153 ms
116,872 KB
testcase_46 AC 149 ms
116,748 KB
testcase_47 AC 138 ms
109,288 KB
testcase_48 AC 149 ms
115,108 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