P8019 [ONTAK2015] OR-XOR

题目描述

给定一个长度为 $n$ 的序列 $a_1, a_2, \cdots, a_n$,请将它划分为 $m$ 段连续的区间,设第 $i$ 段的费用 $c_i$ 为该段内所有数字的异或和,则总费用为 $c_1 \operatorname{or} c_2 \operatorname{or} \cdots \operatorname{or} c_m$。请求出总费用的最小值。

输入格式

第一行,两个整数 $n, m$; 第二行,$n$ 个整数 $a_1, a_2, \cdots, a_n$。

输出格式

一行,一个整数,表示所求的值。

说明/提示

对于 $100\%$ 的数据,$1 \leq m \leq n \leq 5 \times 10^5$,$0 \leq a_i \leq 10^{18}$。