CF1327F.AND Segments

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given three integers nn , kk , mm and mm conditions (l1,r1,x1),(l2,r2,x2),,(lm,rm,xm)(l_1, r_1, x_1), (l_2, r_2, x_2), \dots, (l_m, r_m, x_m) .

Calculate the number of distinct arrays aa , consisting of nn integers such that:

  • 0ai<2k0 \le a_i < 2^k for each 1in1 \le i \le n ;
  • bitwise AND of numbers a[li]&a[li+1]&&a[ri]=xia[l_i] \& a[l_i + 1] \& \dots \& a[r_i] = x_i for each 1im1 \le i \le m .

Two arrays aa and bb are considered different if there exists such a position ii that aibia_i \neq b_i .

The number can be pretty large so print it modulo 998244353998244353 .

输入格式

The first line contains three integers nn , kk and mm ( 1n51051 \le n \le 5 \cdot 10^5 , 1k301 \le k \le 30 , 0m51050 \le m \le 5 \cdot 10^5 ) — the length of the array aa , the value such that all numbers in aa should be smaller than 2k2^k and the number of conditions, respectively.

Each of the next mm lines contains the description of a condition lil_i , rir_i and xix_i ( 1lirin1 \le l_i \le r_i \le n , 0xi<2k0 \le x_i < 2^k ) — the borders of the condition segment and the required bitwise AND value on it.

输出格式

Print a single integer — the number of distinct arrays aa that satisfy all the above conditions modulo 998244353998244353 .

输入输出样例

  • 输入#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, 3, 7, 6] , [3,7,7,6][3, 7, 7, 6] and [7,3,7,6][7, 3, 7, 6] .

首页