結果

問題 No.911 ラッキーソート
ユーザー mkawa2mkawa2
提出日時 2019-11-02 21:15:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,321 bytes
コンパイル時間 72 ms
コンパイル使用メモリ 11,044 KB
実行使用メモリ 143,520 KB
最終ジャッジ日時 2023-10-13 01:30:29
合計ジャッジ時間 42,095 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,220 KB
testcase_01 AC 17 ms
8,260 KB
testcase_02 AC 17 ms
8,196 KB
testcase_03 WA -
testcase_04 AC 17 ms
8,280 KB
testcase_05 WA -
testcase_06 AC 17 ms
8,316 KB
testcase_07 AC 16 ms
8,244 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 16 ms
8,376 KB
testcase_11 WA -
testcase_12 AC 16 ms
8,324 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 WA -
testcase_26 AC 951 ms
59,900 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 27 ms
8,908 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 16 ms
8,204 KB
testcase_34 WA -
testcase_35 AC 17 ms
8,284 KB
testcase_36 RE -
testcase_37 RE -
testcase_38 TLE -
testcase_39 TLE -
testcase_40 WA -
testcase_41 TLE -
testcase_42 WA -
testcase_43 TLE -
testcase_44 TLE -
testcase_45 TLE -
testcase_46 TLE -
testcase_47 TLE -
testcase_48 TLE -
権限があれば一括ダウンロードができます

ソースコード

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 = 60
    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