結果

問題 No.911 ラッキーソート
ユーザー shotoyooshotoyoo
提出日時 2021-07-14 22:42:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 1,226 bytes
コンパイル時間 1,354 ms
コンパイル使用メモリ 86,580 KB
実行使用メモリ 116,004 KB
最終ジャッジ日時 2023-09-17 01:09:10
合計ジャッジ時間 8,409 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,212 KB
testcase_01 AC 71 ms
71,396 KB
testcase_02 AC 71 ms
71,324 KB
testcase_03 AC 72 ms
71,452 KB
testcase_04 AC 76 ms
71,424 KB
testcase_05 AC 67 ms
71,424 KB
testcase_06 AC 68 ms
71,604 KB
testcase_07 AC 69 ms
71,296 KB
testcase_08 AC 65 ms
71,428 KB
testcase_09 AC 66 ms
71,292 KB
testcase_10 AC 66 ms
71,120 KB
testcase_11 AC 65 ms
71,524 KB
testcase_12 AC 68 ms
71,320 KB
testcase_13 AC 153 ms
108,184 KB
testcase_14 AC 169 ms
115,296 KB
testcase_15 AC 156 ms
108,064 KB
testcase_16 AC 179 ms
115,560 KB
testcase_17 AC 176 ms
115,936 KB
testcase_18 AC 170 ms
116,004 KB
testcase_19 AC 170 ms
115,548 KB
testcase_20 AC 154 ms
108,136 KB
testcase_21 AC 171 ms
114,824 KB
testcase_22 AC 168 ms
114,004 KB
testcase_23 AC 151 ms
103,876 KB
testcase_24 AC 149 ms
100,496 KB
testcase_25 AC 122 ms
95,884 KB
testcase_26 AC 113 ms
92,276 KB
testcase_27 AC 92 ms
82,080 KB
testcase_28 AC 83 ms
78,124 KB
testcase_29 AC 78 ms
76,864 KB
testcase_30 AC 74 ms
76,656 KB
testcase_31 AC 70 ms
75,936 KB
testcase_32 AC 68 ms
71,216 KB
testcase_33 AC 73 ms
76,028 KB
testcase_34 AC 68 ms
71,424 KB
testcase_35 AC 70 ms
75,816 KB
testcase_36 AC 67 ms
71,560 KB
testcase_37 AC 71 ms
75,636 KB
testcase_38 AC 168 ms
115,980 KB
testcase_39 AC 173 ms
110,292 KB
testcase_40 AC 76 ms
76,820 KB
testcase_41 AC 167 ms
115,108 KB
testcase_42 AC 131 ms
94,132 KB
testcase_43 AC 163 ms
115,572 KB
testcase_44 AC 132 ms
108,212 KB
testcase_45 AC 150 ms
115,264 KB
testcase_46 AC 137 ms
107,992 KB
testcase_47 AC 134 ms
108,052 KB
testcase_48 AC 143 ms
107,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


n,L,R = list(map(int, input().split()))
a = list(map(int, input().split()))
l = [-1]*62
ng = 0
for i in range(1,n):
    v = a[i]
    p = a[i-1]
    for b in range(62)[::-1]:
        if (v>>b&1) == (p>>b&1):
            continue
        if v>>b&1:
            if l[b]==1:
                ng = 1
                break
            l[b] = 0
        else:
            if l[b]==0:
                ng = 1
                break
            l[b] = 1
        break
    if ng:
        break
def sub(r):
    if r<0:
        return 0
    ll = []
    v = 0
    for i in range(62)[::-1]:
        if l[i]==-1:
            if v+(1<<i)<=r:
                ll.append(1)
                v += (1<<i)
            else:
                ll.append(0)
    v = 1
    res = 0
#     print(ll[-10:])
    for b in ll[::-1]:
        res += b*v
        v *= 2
    return res + 1
if ng:
    ans = 0
else:
    val = 0
    for i in range(62):
        if l[i]==1:
            val += (1<<i)
    ans = sub(R-val) - sub(L-val-1)
print(ans)
0