結果

問題 No.911 ラッキーソート
ユーザー vwxyzvwxyz
提出日時 2023-02-02 06:05:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,441 bytes
コンパイル時間 321 ms
コンパイル使用メモリ 87,024 KB
実行使用メモリ 137,664 KB
最終ジャッジ日時 2023-09-14 14:35:08
合計ジャッジ時間 17,856 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 246 ms
91,292 KB
testcase_01 AC 243 ms
91,152 KB
testcase_02 AC 247 ms
91,040 KB
testcase_03 AC 242 ms
91,144 KB
testcase_04 AC 251 ms
91,072 KB
testcase_05 AC 243 ms
91,164 KB
testcase_06 AC 244 ms
91,396 KB
testcase_07 AC 244 ms
91,144 KB
testcase_08 AC 239 ms
90,908 KB
testcase_09 AC 236 ms
91,136 KB
testcase_10 AC 246 ms
91,312 KB
testcase_11 AC 246 ms
91,264 KB
testcase_12 AC 246 ms
91,140 KB
testcase_13 AC 347 ms
137,664 KB
testcase_14 AC 360 ms
127,464 KB
testcase_15 AC 352 ms
124,648 KB
testcase_16 AC 369 ms
124,416 KB
testcase_17 AC 366 ms
126,656 KB
testcase_18 AC 359 ms
127,416 KB
testcase_19 AC 349 ms
124,516 KB
testcase_20 AC 352 ms
133,372 KB
testcase_21 AC 365 ms
124,376 KB
testcase_22 AC 367 ms
123,612 KB
testcase_23 AC 355 ms
122,296 KB
testcase_24 AC 351 ms
126,180 KB
testcase_25 AC 311 ms
112,244 KB
testcase_26 AC 298 ms
106,580 KB
testcase_27 AC 276 ms
99,404 KB
testcase_28 AC 264 ms
95,452 KB
testcase_29 AC 250 ms
95,028 KB
testcase_30 AC 253 ms
94,472 KB
testcase_31 AC 248 ms
91,728 KB
testcase_32 AC 244 ms
91,396 KB
testcase_33 AC 242 ms
92,084 KB
testcase_34 AC 243 ms
91,304 KB
testcase_35 AC 242 ms
92,000 KB
testcase_36 AC 245 ms
91,048 KB
testcase_37 AC 245 ms
91,764 KB
testcase_38 AC 359 ms
124,332 KB
testcase_39 AC 366 ms
122,312 KB
testcase_40 AC 252 ms
94,884 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 356 ms
124,280 KB
testcase_44 AC 348 ms
137,640 KB
testcase_45 AC 357 ms
130,720 KB
testcase_46 AC 362 ms
126,952 KB
testcase_47 AC 345 ms
124,180 KB
testcase_48 AC 366 ms
130,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
import time
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines
write=sys.stdout.write

N,L,R=map(int,readline().split())
A=list(map(int,readline().split()))
X=[[1,1] for bit in range(62)]
for i in range(N-1):
    for bit in range(61,-1,-1):
        if A[i]&1<<bit!=A[i+1]&1<<bit:
            if A[i]&1<<bit:
                X[bit][0]=0
            else:
                X[bit][1]=0
            break
for bit in range(62):
    if not sum(X[bit]):
        ans=0
        break
else:
    def solve(N):
        bl=X[61][N>>61&1]
        dp=0
        for bit in range(60,-1,-1):
            dp*=sum(X[bit])
            if bl and X[bit][0] and N&1<<bit:
                dp+=1
            bl&=X[bit][N>>bit&1]
        return dp
    ans=solve(R+1)-solve(max(L,1))
    if L==0 and all(A[i]^R<A[i+1]^R for i in range(N-1)):
        ans+=1
print(ans)
0