結果

問題 No.911 ラッキーソート
ユーザー H3PO4H3PO4
提出日時 2021-05-06 09:53:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 272 ms / 2,000 ms
コード長 982 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 36,048 KB
最終ジャッジ日時 2023-10-12 03:00:56
合計ジャッジ時間 12,151 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,812 KB
testcase_01 AC 16 ms
8,156 KB
testcase_02 AC 16 ms
7,720 KB
testcase_03 AC 16 ms
7,808 KB
testcase_04 AC 16 ms
7,796 KB
testcase_05 AC 16 ms
7,868 KB
testcase_06 AC 15 ms
7,784 KB
testcase_07 AC 17 ms
7,812 KB
testcase_08 AC 16 ms
7,812 KB
testcase_09 AC 16 ms
7,848 KB
testcase_10 AC 16 ms
7,816 KB
testcase_11 AC 16 ms
7,732 KB
testcase_12 AC 16 ms
7,892 KB
testcase_13 AC 257 ms
33,352 KB
testcase_14 AC 259 ms
34,596 KB
testcase_15 AC 257 ms
33,348 KB
testcase_16 AC 272 ms
36,048 KB
testcase_17 AC 271 ms
35,756 KB
testcase_18 AC 258 ms
35,644 KB
testcase_19 AC 262 ms
35,000 KB
testcase_20 AC 253 ms
33,500 KB
testcase_21 AC 263 ms
34,620 KB
testcase_22 AC 254 ms
33,792 KB
testcase_23 AC 235 ms
31,112 KB
testcase_24 AC 218 ms
29,780 KB
testcase_25 AC 141 ms
21,084 KB
testcase_26 AC 114 ms
18,560 KB
testcase_27 AC 63 ms
13,092 KB
testcase_28 AC 39 ms
10,640 KB
testcase_29 AC 22 ms
8,980 KB
testcase_30 AC 17 ms
8,416 KB
testcase_31 AC 16 ms
7,888 KB
testcase_32 AC 16 ms
7,812 KB
testcase_33 AC 17 ms
7,808 KB
testcase_34 AC 16 ms
7,724 KB
testcase_35 AC 16 ms
7,808 KB
testcase_36 AC 16 ms
7,892 KB
testcase_37 AC 16 ms
7,812 KB
testcase_38 AC 261 ms
36,020 KB
testcase_39 AC 254 ms
34,380 KB
testcase_40 AC 22 ms
8,900 KB
testcase_41 AC 262 ms
34,316 KB
testcase_42 AC 171 ms
24,380 KB
testcase_43 AC 259 ms
34,916 KB
testcase_44 AC 120 ms
33,280 KB
testcase_45 AC 151 ms
34,920 KB
testcase_46 AC 112 ms
35,204 KB
testcase_47 AC 136 ms
33,604 KB
testcase_48 AC 124 ms
33,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, L, R = map(int, input().split())
A = tuple(map(int, input().split()))

table = [None] * 61


def is_impossible(flag):
    if flag: print(0);exit()


def set_table(x, q):
    if table[x] is None:
        table[x] = q
    else:
        is_impossible(table[x] != q)


for i in range(N - 1):
    diff = A[i + 1] - A[i]
    x = A[i + 1] ^ A[i]
    is_impossible(diff == 0)
    if diff > 0:
        set_table(x.bit_length() - 1, 0)
    elif diff < 0:
        set_table(x.bit_length() - 1, 1)


def f(x):
    if x < 0: return 0

    dp_same, dp_smaller = 1, 0
    for i in range(60, -1, -1):
        t = table[i]
        if (x >> i) & 1:
            if t is None:
                dp_smaller = dp_same + dp_smaller * 2
            elif t == 0:
                dp_same, dp_smaller = 0, dp_same + dp_smaller
        else:
            if t is None:
                dp_smaller *= 2
            elif t == 1:
                dp_same = 0
    return dp_same + dp_smaller


print(f(R) - f(L - 1))
0