結果

問題 No.911 ラッキーソート
ユーザー mkawa2mkawa2
提出日時 2019-11-02 21:17:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,321 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 11,100 KB
実行使用メモリ 161,680 KB
最終ジャッジ日時 2023-10-13 01:30:49
合計ジャッジ時間 5,782 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
12,676 KB
testcase_01 AC 16 ms
8,356 KB
testcase_02 AC 16 ms
8,308 KB
testcase_03 AC 17 ms
8,368 KB
testcase_04 AC 16 ms
8,224 KB
testcase_05 AC 17 ms
8,316 KB
testcase_06 AC 17 ms
8,304 KB
testcase_07 AC 16 ms
8,396 KB
testcase_08 AC 17 ms
8,136 KB
testcase_09 AC 17 ms
8,080 KB
testcase_10 AC 16 ms
8,288 KB
testcase_11 AC 16 ms
8,188 KB
testcase_12 AC 16 ms
8,172 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
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

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 not lr: return 0
        dp = [[0] * 2 for _ in range(max_k + 1)]
        dp[0][0] = 1
        for i in range(max_k):
            for f in range(2):
                pre = dp[i][f]
                if pre == 0: continue
                nf = f
                if dig[i] < 1 and (f == 1 or lr[i] == 1):
                    dp[i + 1][nf] += pre
                if dig[i] > -1:
                    if lr[i] == 1: nf = 1
                    dp[i + 1][nf] += pre
        return sum(dp[max_k])

    max_k = 65
    blst = lambda x: list(map(int, list(format(int(x), "b").zfill(max_k))))
    n, l, r = map(int, input().split())
    l = [] if l == 0 else blst(l - 1)
    r = blst(r)
    aa = list(map(blst, input().split()))
    # p2D(aa)
    dig = [0] * max_k  # 1昇順 -1降順 0どちらでも
    for a0, a1 in zip(aa, aa[1:]):
        for i, (a0k, a1k) in enumerate(zip(a0, a1)):
            if a0k != a1k:
                if dig[i] == a0k - a1k:
                    print(0)
                    exit()
                else:
                    dig[i] = a1k - a0k
                    break
    # print(dig)
    print(bitdp(r) - bitdp(l))

main()
0