結果

問題 No.911 ラッキーソート
ユーザー mkawa2mkawa2
提出日時 2019-11-02 21:18:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,155 ms / 2,000 ms
コード長 1,321 bytes
コンパイル時間 394 ms
コンパイル使用メモリ 87,032 KB
実行使用メモリ 237,576 KB
最終ジャッジ日時 2023-10-13 01:33:30
合計ジャッジ時間 26,805 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,292 KB
testcase_01 AC 74 ms
71,292 KB
testcase_02 AC 73 ms
71,296 KB
testcase_03 AC 79 ms
75,856 KB
testcase_04 AC 80 ms
75,816 KB
testcase_05 AC 79 ms
75,656 KB
testcase_06 AC 78 ms
75,776 KB
testcase_07 AC 78 ms
75,652 KB
testcase_08 AC 79 ms
75,884 KB
testcase_09 AC 79 ms
75,772 KB
testcase_10 AC 76 ms
71,276 KB
testcase_11 AC 79 ms
75,744 KB
testcase_12 AC 79 ms
75,920 KB
testcase_13 AC 1,000 ms
236,788 KB
testcase_14 AC 1,155 ms
237,488 KB
testcase_15 AC 899 ms
237,576 KB
testcase_16 AC 924 ms
237,432 KB
testcase_17 AC 904 ms
237,432 KB
testcase_18 AC 910 ms
237,480 KB
testcase_19 AC 914 ms
237,280 KB
testcase_20 AC 886 ms
236,672 KB
testcase_21 AC 901 ms
234,788 KB
testcase_22 AC 876 ms
232,276 KB
testcase_23 AC 824 ms
220,936 KB
testcase_24 AC 766 ms
207,224 KB
testcase_25 AC 512 ms
158,208 KB
testcase_26 AC 411 ms
136,756 KB
testcase_27 AC 241 ms
105,212 KB
testcase_28 AC 168 ms
90,700 KB
testcase_29 AC 108 ms
80,520 KB
testcase_30 AC 87 ms
76,308 KB
testcase_31 AC 82 ms
76,044 KB
testcase_32 AC 78 ms
74,984 KB
testcase_33 AC 81 ms
76,116 KB
testcase_34 AC 76 ms
71,364 KB
testcase_35 AC 80 ms
76,124 KB
testcase_36 AC 80 ms
75,728 KB
testcase_37 AC 79 ms
75,920 KB
testcase_38 AC 927 ms
237,396 KB
testcase_39 AC 866 ms
224,520 KB
testcase_40 AC 112 ms
80,728 KB
testcase_41 AC 906 ms
236,252 KB
testcase_42 AC 604 ms
175,064 KB
testcase_43 AC 899 ms
237,424 KB
testcase_44 AC 857 ms
237,360 KB
testcase_45 AC 881 ms
237,224 KB
testcase_46 AC 870 ms
237,072 KB
testcase_47 AC 861 ms
237,028 KB
testcase_48 AC 837 ms
230,036 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 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