CF1327F.AND Segments
省选/NOI-
通过率:0%
时间限制:3.00s
内存限制:256MB
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.
给你三个整数 n、k、m,以及 m 个条件 (l1,r1,x1),(l2,r2,x2),…,(lm,rm,xm)。
请计算满足以下条件的、由 n 个整数组成的不同数组 a 的个数:
- 对每个 1≤i≤n,均有 0≤ai<2k;
- 对每个 1≤i≤m,子数组 a[li]&a[li+1]&…&a[ri] 的按位与结果等于 xi。
若存在某个位置 i 使得 ai=bi,则称两个数组 a 和 b 不同。
答案可能非常大,请对 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.
第一行包含三个整数 n、k 和 m(1≤n≤5⋅105,1≤k≤30,0≤m≤5⋅105),分别表示数组 a 的长度、要求数组 a 中所有数均小于 2k 的参数 k,以及约束条件的个数。
接下来的 m 行每行描述一个约束条件,包含 li、ri 和 xi(1≤li≤ri≤n,0≤xi<2k),分别表示该约束条件对应区间的左右端点以及该区间上所有元素按位与(bitwise AND)运算结果的要求值。
输出格式
Print a single integer — the number of distinct arrays a that satisfy all the above conditions modulo 998244353.
输出一个整数——满足上述所有条件的不同数组 a 的个数对 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
输入解题思路,AI测评打分。不知道怎么写?