CF1327F.AND Segments
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given three integers n , k , m and m conditions (l1,r1,x1),(l2,r2,x2),…,(lm,rm,xm) .
Calculate the number of distinct arrays a , consisting of n integers such that:
- 0≤ai<2k for each 1≤i≤n ;
- bitwise AND of numbers a[li]&a[li+1]&…&a[ri]=xi for each 1≤i≤m .
Two arrays a and b are considered different if there exists such a position i that ai=bi .
The number can be pretty large so print it modulo 998244353 .
输入格式
The first line contains three integers n , k and m ( 1≤n≤5⋅105 , 1≤k≤30 , 0≤m≤5⋅105 ) — the length of the array a , the value such that all numbers in a should be smaller than 2k and the number of conditions, respectively.
Each of the next m lines contains the description of a condition li , ri and xi ( 1≤li≤ri≤n , 0≤xi<2k ) — the borders of the condition segment and the required bitwise AND value on it.
输出格式
Print a single integer — the number of distinct arrays a that satisfy all the above conditions modulo 998244353 .
输入输出样例
输入#1
4 3 2 1 3 3 3 4 6
输出#1
3
输入#2
5 2 3 1 3 2 2 5 0 3 3 3
输出#2
33
说明/提示
You can recall what is a bitwise AND operation here.
In the first example, the answer is the following arrays: [3,3,7,6] , [3,7,7,6] and [7,3,7,6] .