結果

問題 No.911 ラッキーソート
ユーザー convexineqconvexineq
提出日時 2021-04-11 17:22:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 578 ms / 2,000 ms
コード長 750 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 191,224 KB
最終ジャッジ日時 2023-09-09 19:28:59
合計ジャッジ時間 17,138 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,172 KB
testcase_01 AC 72 ms
71,372 KB
testcase_02 AC 74 ms
71,228 KB
testcase_03 AC 73 ms
71,240 KB
testcase_04 AC 73 ms
71,200 KB
testcase_05 AC 74 ms
71,128 KB
testcase_06 AC 75 ms
71,180 KB
testcase_07 AC 73 ms
71,108 KB
testcase_08 AC 72 ms
71,304 KB
testcase_09 AC 72 ms
71,288 KB
testcase_10 AC 71 ms
71,240 KB
testcase_11 AC 72 ms
71,276 KB
testcase_12 AC 73 ms
71,104 KB
testcase_13 AC 396 ms
158,912 KB
testcase_14 AC 381 ms
153,552 KB
testcase_15 AC 386 ms
166,780 KB
testcase_16 AC 420 ms
164,672 KB
testcase_17 AC 405 ms
163,668 KB
testcase_18 AC 416 ms
163,788 KB
testcase_19 AC 412 ms
160,392 KB
testcase_20 AC 426 ms
167,364 KB
testcase_21 AC 544 ms
191,224 KB
testcase_22 AC 578 ms
174,276 KB
testcase_23 AC 482 ms
175,804 KB
testcase_24 AC 454 ms
163,712 KB
testcase_25 AC 327 ms
147,184 KB
testcase_26 AC 263 ms
106,632 KB
testcase_27 AC 177 ms
84,876 KB
testcase_28 AC 140 ms
80,372 KB
testcase_29 AC 107 ms
77,400 KB
testcase_30 AC 95 ms
76,152 KB
testcase_31 AC 84 ms
76,188 KB
testcase_32 AC 72 ms
71,128 KB
testcase_33 AC 78 ms
75,868 KB
testcase_34 AC 72 ms
71,172 KB
testcase_35 AC 79 ms
75,876 KB
testcase_36 AC 79 ms
76,080 KB
testcase_37 AC 78 ms
76,080 KB
testcase_38 AC 405 ms
163,160 KB
testcase_39 AC 487 ms
174,640 KB
testcase_40 AC 104 ms
77,608 KB
testcase_41 AC 421 ms
163,184 KB
testcase_42 AC 338 ms
136,116 KB
testcase_43 AC 378 ms
151,336 KB
testcase_44 AC 379 ms
158,892 KB
testcase_45 AC 393 ms
153,864 KB
testcase_46 AC 396 ms
155,020 KB
testcase_47 AC 368 ms
154,676 KB
testcase_48 AC 422 ms
160,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,L,R = map(int,input().split())
*a, = map(int,input().split())
res = [3]*62
q = [a]
for i in range(62)[::-1]:
    #print(q)
    nq = []
    c = 3
    for lst in q:
        q0 = []
        q1 = []
        for x in lst:
            if x>>i&1:
                q1.append(x)
                if q0: c &= 1
            else:
                q0.append(x)
                if q1: c &= 2
        if len(q0) >= 2: nq.append(q0)
        if len(q1) >= 2: nq.append(q1)
    res[i] = c
    q = nq

d = {}
def f(x,i):
    if (x,i) in d:
        return d[x,i]
    if x < 0: return 0
    if i==62: return 1
    c = 0
    if res[i]&1:
        c += f(x//2,i+1)
    if res[i]&2:
        c += f((x-1)//2,i+1)
    d[x,i] = c
    return c

p = f(R,0)
q = f(L-1,0)
print(p-q)
0