第二十一篇英文翻译
重点单词:
constrain v.约束,限制,强迫;
per prep.每一,每个,按照,根据;
contiguous adj.连续的,邻近的,接触的;
segment n.部分,片段,节;v.分割,划分;
compute v.估算,计算 n.计算,估计;
出处:https://acs.jxnu.edu.cn/contest/24/board/challenge/E
Divan and bitwise operations
描述:
Divan and bitwise operations
描述:
Once Divan analyzed a sequence a1,a2,…,an consisting of n non-negative integers as follows. He considered each non-empty subsequence of the sequence a, computed the bitwise XOR of its elements and added up all the XORs, obtaining the coziness of the sequence a.
Divan分析了一个序列a1,a2,…,a由n个非负整数组成,如下所示。他考虑序列a的每个非空子序列,计算其元素的按位异或,并将所有异或相加,得到序列a的舒适度。
如果可以通过删除几个(可能是零个或全部)元素从d中获得c,则序列c是序列d的子序列。例如,[1,2,3,4]、[2,4]和[2]是[1,2,3,4]的子序列,但[4,3]和[0]不是。
A sequence c is a subsequence of a sequence d if c can be obtained from d by deletion of several (possibly, zero or all) elements. For example, [1,2,3,4], [2,4], and [2] are subsequences of [1,2,3,4], but [4,3] and [0] are not.
Divan was very proud of his analysis, but now he lost the sequence a, and also the coziness value! However, Divan remembers the value of bitwise OR on m contiguous subsegments of the sequence a. It turns out that each element of the original sequence is contained in at least one of these m segments.
Divan asks you to help find the coziness of the sequence a using the information he remembers. If several coziness values are possible, print any.
As the result can be very large, print the value modulo 109+7.
迪万对他的分析感到非常自豪,但现在他失去了序列a,也失去了舒适的价值!然而,Divan会记住序列a的m个相邻子段上的按位或的值。结果表明,原始序列的每个元素都包含在这些m个段中的至少一个段中。
Divan要求你利用他记忆中的信息来帮助寻找序列a的舒适性。如果可能有多个舒适度值,请打印任意值。
由于结果可能非常大,请以109+7的模打印值。
输入:
The first line contains one integer number t (1≤t≤103) — the number of test cases.
The first line of each test case contains two integer numbers n and m (1≤n,m≤2⋅105) — the length of the sequence and the number of contiguous segments whose bitwise OR values Divan remembers, respectively.
The following m lines describe the segments, one per line.
Each segment is described with three integers l, r, and x (1≤l≤r≤n, 0≤x≤230−1) — the first and last elements of the segment and the bitwise OR of al,al+1,…,ar, respectively.
It is guaranteed that each element of the sequence is contained in at least one of the segments. It is guaranteed that there exists a sequence that satisfies all constraints.
第一行包含一个整数t(1≤T≤103)-测试用例的数量。
每个测试用例的第一行包含两个整数n和m(1)≤n、 m≤2.⋅105)-序列的长度和按位或Divan分别记住的连续段数。
以下m条线描述了各段,每条线一条。
每个段用三个整数l、r和x(1)描述≤L≤R≤n、 0≤十、≤230−1) -段的第一个和最后一个元素,以及al,al+1,…,ar的按位OR。
保证序列的每个元素都包含在至少一个片段中。保证存在满足所有约束的序列。
保证所有测试用例中n和m之和不超过2⋅105
It is guaranteed that the sum of n and the sum of m over all test cases do not exceed 2⋅105.
输出:
For each test case print the coziness any suitable sequence a modulo 109+7.
样例输入:
3
2 1
1 2 2
3 2
1 3 5
2 3 5
5 4
1 2 7
3 3 7
4 4 0
4 5 2
复制
样例输出:
4
20
112
复制
注释:
In first example, one of the sequences that fits the constraints is [0,2]. Consider all its non-empty subsequences:
[0]: the bitwise XOR of this subsequence is 0;
[2]: the bitwise XOR of this subsequence is 2;
[0,2]: the bitwise XOR of this subsequence is 2.
The sum of all results is 4, so it is the answer.
In second example, one of the sequences that fits the constraints is [0,5,5].
In third example, one of the sequences that fits the constraints is [5,6,7,0,2].
在第一个示例中,符合约束条件的序列之一是[0,2]。考虑其所有非空子序列:
[0]:此子序列的按位异或为0;
[2] :此子序列的按位异或为2;
[0,2]:此子序列的按位异或为2。
所有结果之和是4,所以这就是答案。
在第二个示例中,符合约束条件的序列之一是[0,5,5]。
在第三个示例中,符合约束条件的序列之一是[5,6,7,0,2]。