結果
| 問題 |
No.911 ラッキーソート
|
| コンテスト | |
| ユーザー |
vwxyz
|
| 提出日時 | 2023-02-02 06:04:07 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,432 bytes |
| コンパイル時間 | 174 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 123,904 KB |
| 最終ジャッジ日時 | 2024-07-01 21:53:30 |
| 合計ジャッジ時間 | 12,571 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 WA * 8 |
ソースコード
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(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][0]=0
else:
X[bit][1]=0
break
for bit in range(61):
if not sum(X[bit]):
ans=0
break
else:
def solve(N):
bl=X[60][N>>60&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)-solve(L)
if L==0 and all(A[i]^R<A[i+1]^R for i in range(N-1)):
ans+=1
print(ans)
vwxyz