CF1930F.Maximize the Difference
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
For an array b of m non-negative integers, define f(b) as the maximum value of i=1maxm(bi∣x)−i=1minm(bi∣x) over all possible non-negative integers x , where ∣ is bitwise OR operation.
You are given integers n and q . You start with an empty array a . Process the following q queries:
- v : append v to the back of a and then output f(a) . It is guaranteed that 0≤v<n .
The queries are given in a modified way.
输入格式
Each test contains multiple test cases. The first line contains a single integer t ( 1≤t≤2⋅105 ) — the number of test cases. The description of the test cases follows.
The first line of each test case contains two integers n and q ( 1≤n≤222 , 1≤q≤106 ) — the number of queries.
The second line of each test case contains q space-separated integers e1,e2,…,eq ( 0≤ei<n ) — the encrypted values of v .
Let lasti equal the output of the (i−1) -th query for i≥2 and lasti=0 for i=1 . Then the value of v for the i -th query is ( ei+lasti ) modulo n .
It is guaranteed that the sum of n over all test cases does not exceed 222 and the sum of q over all test cases does not exceed 106 .
输出格式
For each test case, print q integers. The i -th integer is the output of the i -th query.
输入输出样例
输入#1
2 5 2 1 2 7 4 3 1 5 2
输出#1
0 2 0 2 3 5
说明/提示
In the first test case, the final a=[1,2] . For i=1 , the answer is always 0 , irrespective of x . For i=2 , we can select x=5 .
In the second test case, the final a=[3,1,0,5] .