#P7483. 50 年后的我们

    ID: 8390 远端评测题 1000ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划 DPO2优化动态规划优化组合数学二项式定理容斥原理

50 年后的我们

Background

YSGHYYDS.

Problem Description

YSGH prepared nn problems for a contest. The difficulty of problem ii is did_i, and its value is cic_i.

There are mm potential contestants. Contestant ii participates in the contest with probability pip_i. If contestant ii participates, then they will solve exactly all problems whose difficulties are between lil_i and rir_i (including lil_i and rir_i).

The contest committee will finally award YSGH a bonus equal to the kk-th power of the sum of values of all problems that are solved by at least one contestant. In particular, we define 00=10^0 = 1.

You need to help YSGH compute the expected value of the bonus.

Let P=998244353P=998244353. Suppose a rational number xx is written in lowest terms as ab\frac{a}{b}. If gcd(b,P)=1\gcd(b,P)=1, then there exists a unique integer cc (0c<P0 \le c < P) such that bca(modP)b c \equiv a \pmod{P}. We call this cc the value of xx modulo PP.

It can be proven that even if only the value of pip_i modulo PP is given, the answer still exists uniquely modulo PP.

Input Format

The first line contains three integers n,m,kn, m, k, representing the number of problems, the number of potential contestants, and the parameter used to compute the bonus.

The next nn lines each contain two integers di,cid_i, c_i, representing the difficulty and value of problem ii.

The next mm lines each contain three integers li,ri,pil_i, r_i, p_i, representing the difficulty interval of problems that contestant ii can solve, and the probability (given modulo PP) that they participate in the contest.

Output Format

Output one line with one integer, representing the expected value of the bonus modulo PP.

5 2 1
346 412
464 685
895 544
976 322
612 121
346 712 2
850 932 3

4068

5 2 2
346 412
464 685
895 544
976 322
612 121
233 749 798465123
698 985 151455772

105133973

Hint

Sample Explanation #1

This sample satisfies Special Property A.

If the first person participates, they can solve problems 1,2,51, 2, 5.

If the second person participates, they can solve problem 33.

So the expected bonus of YSGH is $(412+685+121)\times 2\times (1-3)+544\times (1-2)\times 3+(412+685+121+544)\times 2\times 3\equiv 4068\pmod{P}$.


Constraints

This problem uses bundled testdata.

For 100%100\% of the testdata, 1n4001\le n\le 400, 0k4000\le k\le 400, 1m1051\le m\le 10^5, 1di1091\le d_i\le 10^9, 1liri1091\le l_i\le r_i\le 10^9, 0ci,pi<9982443530\le c_i,p_i < 998244353.

The special constraints and scores of each Subtask are as follows:

Test Package ID nn\le kk\le Other Constraints Score
11 400400 11 Special Property A 55
22 None 66
33 22 Special Property A 77
44 None 88
66 1818 100100 Special Property A 33
55 None 1515
77 100100 Special Property A 99
88 None 1616
99 400400 Special Property A 1010
1010 None 2121

Special Property A: For any 1i<jM1\le i < j\le M, we have [li,ri][lj,rj]=[l_i,r_i]\cap [l_j,r_j]=\varnothing.

Translated by ChatGPT 5