結果

問題 No.911 ラッキーソート
ユーザー treeonetreeone
提出日時 2019-10-18 14:03:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,115 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 10,956 KB
実行使用メモリ 38,012 KB
最終ジャッジ日時 2023-09-07 20:32:51
合計ジャッジ時間 6,076 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,848 KB
testcase_01 AC 16 ms
8,184 KB
testcase_02 AC 16 ms
8,316 KB
testcase_03 AC 16 ms
8,316 KB
testcase_04 AC 16 ms
8,352 KB
testcase_05 AC 17 ms
8,232 KB
testcase_06 AC 16 ms
8,332 KB
testcase_07 AC 16 ms
8,224 KB
testcase_08 AC 16 ms
8,316 KB
testcase_09 AC 16 ms
8,264 KB
testcase_10 AC 15 ms
8,128 KB
testcase_11 AC 16 ms
8,224 KB
testcase_12 AC 16 ms
8,332 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
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 #

use = [[0 for j in range(2)] for i in range(61)]

def calc(M):
    dp = [0] * 2
    nxt = [0] * 2
    dp[1] = 1
    for i in range(60, -1, -1):
        nxt[0] = 0
        nxt[1] = 0
        nxt[0] += dp[0] * use[i][0]
        nxt[0] += dp[0] * use[i][1]
        if M & (1 << i) != 0:
            nxt[0] += dp[1] * use[i][0]
            nxt[1] += dp[1] * use[i][1]
        else:
            nxt[1] += dp[1] * use[i][0]
        dp[0] = nxt[0]
        dp[1] = nxt[1]
    return dp[0] + dp[1]


N, L, R = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

v = [0, N]
for i in range(60, -1, -1):
    use[i][0] = 1
    use[i][1] = 1
    tmp = v
    for j in range(len(v) - 1):
        cnt = 0
        for k in range(v[j] + 1, v[j + 1]):
            if ((A[k - 1] & (1 << i)) == 0) != ((A[k] & (1 << i)) == 0):
                cnt += 1
                tmp.append(k)
        if cnt >= 2:
            use[i][0] = 0
            use[i][1] = 0
        elif cnt == 1:
            use[i][((A[v[j]] & (1 << i)) == 0)] = 0
    tmp.sort()
    v = tmp

ans = calc(R)
if L != 0:
    ans -= calc(L - 1)
print(ans)
0