33OJ
登录 注册

#P17634. [ICPC 2019 Yinchuan R] Image Processing

    ID: 20139 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度省选/NOI− 上传者: 标签>动态规划 DP2019线段树单调队列ICPC双指针 two-pointer

[ICPC 2019 Yinchuan R] Image Processing

Problem Description

Brabo has nn images and an image processing APP. The ii-th image, for any 1≤i≤n1\leq i\leq n, has a contrast value viv_i. To make the images better, the APP receives a batch of images together (which contains at least kk images) and the contrast between these images should be as close as possible.

Brabo has already known the contrast values viv_i of all these images, and now he has to determine a partition splitting images into groups so that each group has at least kk images, and each image should belong to a certain group. Moreover, the maximal difference of contrast values for images in the same group should be as small as possible. Note that Brabo cannot rearrange the order of these images. That is, each group must contain several images with continuous indexes.

Let's denote cic_i as the smallest maximal difference of contrast values for splitting the first ii images into groups. Your task is to compute these values: c1,c2,⋯ ,cnc_1, c_2, \cdots, c_n. Note that when it is impossible to partition the first ii images, cic_i is regarded as 00.

Input Format

The first line contains two integers n (1≤n≤1000000)n~(1 \le n \le 1000000) and k (1≤k≤n)k~(1 \le k \le n) --- the number of images, and each group of images should contain no less than kk images.

The next line contains nn integers x1,x2,⋯ ,xn (0≤xi≤2×109)x_1, x_2, \cdots, x_n~(0 \le x_i \le 2\times 10^9) --- the encrypted contrast viv_i of these images. The actual viv_i is xi⊕ci−1x_i\oplus c_{i-1}, where ⊕\oplus denotes bitwise exclusive-or. Note that c0=0c_0=0. It is guaranteed that 1≤vi≤1091\leq v_i\leq 10^9 after decryption.

Output Format

Output nn lines, where the ii-th (1≤i≤n)(1\le i \le n) line contains a single integer, the smallest contrast differences cic_i.

5 2
50 110 190 120 34
0
60
80
90
80

Hint

In the sample test, v=[50,110,130,40,120]v=[50,110,130,40,120].