XOr

시간 제한1초메모리 제한1024 MB

요약
수열을 정확히 m개의 연속한 부분으로 나눌 때, 각 부분의 XOR 합들을 모두 OR한 값이 최소가 되도록 한다.
난이도

어려움10점 중 8점

유형
비트 연산, 누적 합, 그리디, 동적 계획법
정답자
아직 제출이 없습니다

문제

bobo has a sequence of integers a_1,a_2,…,a_na\_1, a\_2, \dots, a\_n. He decides to divide the sequence into exactly mm consecutive parts.

The cost of each part is its xor sum (bitwise exclusive-or), while the cost of division is bitwise or-sum of its parts' costs.

Help bobo find the minimum cost.

입력

The first line contains 22 integers n,mn, m (1≤n≤200000,1≤m≤n1 \leq n \leq 200000, 1 \leq m \leq n).

The second line contains nn integers a_1,a_2,…,a_na\_1, a\_2, \dots, a\_n (0≤a_i≤1090 \leq a\_i \leq 10^9).

출력

A single integer denotes the minimum cost.

예제2

  1. 예제 1

    입력
    3 2
    1 3 2
    
    예상 출력
    1
    
  2. 예제 2

    입력
    4 3
    1 2 0 2
    
    예상 출력
    3