#P16732. [GKS 2019 #D] X or What?

    ID: 16980 Type: RemoteJudge 3000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 5 Uploaded By: Tags>2019前缀和STLGoogle Kick Start

[GKS 2019 #D] X or What?

题目描述

Steven has an array of NN non-negative integers. The ii-th integer (indexed starting from 0) in the array is AiA_i.

Steven really likes subintervals of AA that are xor-even. Formally, a subinterval of AA is a pair of indices (L,R)(L, R), denoting the elements AL,AL+1,...,AR−1,ARA_L, A_{L+1}, ..., A_{R-1}, A_R. The xor-sum of this subinterval is $A_L \text{ xor } A_{L+1} \text{ xor } ... \text{ xor } A_{R-1} \text{ xor } A_R$, where xor is the bitwise exclusive or.

A subinterval is xor-even if its xor-sum has an even number of set bits in its binary representation.

Steven would like to make QQ modifications to the array. The ii-th modification changes the PiP_i-th (indexed from 0) element to ViV_i. Steven would like to know, what is the size of the xor-even subinterval of A with the most elements after each modification?

输入格式

The first line of the input gives the number of test cases, TT. TT test cases follow.

Each test case starts with a line containing two integers NN and QQ, denoting the number of elements in Steven's array and the number of modifications, respectively.

The second line contains NN integers. The ii-th of them gives AiA_i indicating the ii-th integer in Steven's array.

Then, QQ lines follow, describing the modifications. The ii-th line contains PiP_i and ViV_i. The ii-th modification changes the PiP_i-th element to ViV_i, indicating that the ii-th modification changes the PiP_i-th (indexed from 0) element to ViV_i.

输出格式

For each test case, output one line containing Case #x: y_1 y_2 . . . y_Q, where x is the test case number (starting from 1) and y_i is the number of elements in the largest xor-even subinterval of AA after the ii-th modification. If there are no xor-even subintervals, then output 0.

2
4 3
10 21 3 7
1 13
0 32
2 22
5 1
14 1 15 20 26
4 26
Case #1: 4 3 4
Case #2: 4

提示

In Sample Case 1, N=4N = 4 and Q=3Q = 3.

  • After the 1st modification, AA is [10,13,3,7][10, 13, 3, 7]. The subinterval (0,3)(0, 3) has xor-sum $10 \text{ xor } 13 \text{ xor } 3 \text{ xor } 7 = 3$. In binary, the xor-sum is 11211_2, which has an even number of 11 bits, so the subinterval is xor-even. This is the largest subinterval possible, so the answer is 44.
  • After the 2nd modification, AA is [32,13,3,7][32, 13, 3, 7]. The largest xor-even subinterval is (0,2)(0, 2), which has xor-sum 32 xor 13 xor 3=4632 \text{ xor } 13 \text{ xor } 3 = 46. In binary, this is 1011102101110_2.
  • After the 3rd modification, AA is [32,13,22,7][32, 13, 22, 7]. The largest xor-even subinterval is (0,3)(0, 3) again, which has xor-sum $32 \text{ xor } 13 \text{ xor } 22 \text{ xor } 7 = 60$. In binary, this is 1111002111100_2.

In Sample Case 2, N=5N = 5 and Q=1Q = 1. After the 1st modification, AA is [14,1,15,20,26][14, 1, 15, 20, 26]. The largest xor-even subinterval is (1,4)(1, 4), which has xor sum $1 \text{ xor } 15 \text{ xor } 20 \text{ xor } 26 = 0$. In binary, this is 020_2.

Limits

1≤T≤1001 \le T \le 100.

0≤Ai<10240 \le A_i < 1024.

0≤Pi<N0 \le P_i < N.

0≤Vi<10240 \le V_i < 1024.

Test set 1 (Visible)

1≤N≤1001 \le N \le 100.

1≤Q≤1001 \le Q \le 100.

Test set 2 (Hidden)

1≤N≤1051 \le N \le 10^5.

1≤Q≤1051 \le Q \le 10^5.