結果
| 問題 |
No.911 ラッキーソート
|
| コンテスト | |
| ユーザー |
vwxyz
|
| 提出日時 | 2023-02-02 05:41:43 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,431 bytes |
| コンパイル時間 | 247 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 38,796 KB |
| 最終ジャッジ日時 | 2024-07-01 21:33:07 |
| 合計ジャッジ時間 | 22,822 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 TLE * 8 -- * 28 |
ソースコード
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=[{0,1} for bit in range(61)]
for i in range(N-1):
for bit in range(60,-1,-1):
if A[i]&1<<bit!=A[i+1]&1<<bit:
if A[i]&1<<bit:
X[bit].discard(0)
else:
X[bit].discard(1)
break
for bit in range(61):
if not X[bit]:
ans=0
break
else:
def solve(N):
bl=(N>>60&1 in X[60])
dp=0
if N&1<<60 and 0 in X[60]:
dp+=1
for bit in range(59,-1,-1):
dp*=len(X[bit])
if bl and 0 in X[bit] and N&1<<bit:
dp+=1
bl&=(N>>bit&1 in X[bit])
return dp
ans=solve(R+1)-solve(L)
print(ans)
vwxyz