luogu#P10256. 高仿的 Migos

    ID: 9039 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>线段树洛谷原创洛谷月赛动态 DP全局平衡二叉树

高仿的 Migos

Problem Description

After hard training, ZHY finally became a rapper. But one day, rapper ZHY saw works by the peer rap group Migos, and immediately realized the gap between them. So he wants to learn Migos' rap skills and reproduce Migos' success.

After researching for several days and nights, ZHY finally selected nn rap works of Migos, numbered 1,2,,n1,2,\dots,n in order. He believes that as long as he finishes learning these nn works, he can become a better rapper. Therefore, he will start from work 11, and learn them one by one in increasing order. After finishing work nn, he ends his learning.

However, rapper ZHY has a very special way of learning. For each work, he only listens for 11 minute. The problem with this learning method is that for work ii, after spending 11 minute, he may succeed or fail. Specifically, if ZHY is learning work ii, then after he spends one minute learning:

  • With probability PiP_i, ZHY succeeds, and then he will continue to learn work i+1i+1 (of course, if i=ni=n, he ends the learning directly).
  • With probability 1Pi1-P_i, ZHY fails. Unfortunately, the memory in his brain will become confused, causing him to remember only the first xix_i works, i.e. he must restart learning from work xi+1x_i+1.

After trying to learn several times, ZHY was deeply troubled by the memory confusion, so he asked brain science expert YHZ for help. After YHZ's research, he found that all xix_i follow a certain pattern. Specifically, he found mm pairs of natural numbers (li,ri)(l_i,r_i), where i=1,2,mi=1,2\dots,m, satisfying 0li<rin0\leq l_i<r_i\leq n. Then $x_i=\max\limits_{j=1}^m\{l_j \mid l_j+1\leq i\leq r_j\}$. In particular, if for all 1jm1\leq j\leq m, it is not true that lj+1irjl_j+1\leq i\leq r_j, then xi=0x_i=0.

Now ZHY has fully understood his learning ability, but the previous attempts made him exhausted, so he decided to rest for 11 second, and hopes you can help him compute the expected number of minutes he needs to finish learning. However, he realized that learning each work for a fixed 11 minute is not comprehensive enough, so he decided to change the one minute he spends on some works, which will change the success probability of learning that work. Specifically, ZHY now提出 (pinyin: tichu) kk requests, and each request is one of the following two types:

  1. Modify the success probability PiP_i of some work ii.
  2. Query the expected number of minutes needed to finish learning all nn works under the current probabilities.

Since ZHY needs to rest, he turned to you and hopes you can handle his requests. For each request of the second type, you should output the expected time modulo 109+710^9+7. ZHY gave you 11 second, because he can only rest for that long.

Input Format

The first line contains three integers n,m,kn,m,k, with the meaning as described above.

In the next nn lines, each line contains two positive integers pi,qip_i,q_i, meaning Pi=piqiP_i=\frac{p_i}{q_i}.

In the next mm lines, each line contains two integers li,ril_{i},r_{i}.

In the next kk lines, each line is in one of the following two formats:

  • 1 x a b is a modification operation, meaning PxP_x becomes ab\frac a b. It is guaranteed that 1xn1\le x \le n, 1ab<109+71 \le a \le b < 10^9+7, and x,a,bx,a,b are all positive integers.
  • 2 is a query operation, meaning to ask what the expected time to finish learning is at this moment, modulo 109+710^9+7.

Output Format

For each query, output one integer per line representing the answer.

3 1 3
1 3
2 3
1 4
2 3
2
1 2 4 5
2
10
9
2 1 1
1 1
1 2
0 2
2
4
2 1 1
1 1
1 2
1 2
2
3

Hint

This problem uses bundled testdata.

Subtask ID nn mm kk Special Property Score
00 300\le 300 None 1111
11 3000\le 3000 44
22 105\le 10^5 105\le 10^5 1\le 1 B 55
33 None 1414
44 =0=0 105\le 10^5 1919
55 105\le 10^5 A
66 B 88
77 C 1010
88 None

All “intervals” below refer to [li,ri][l_i,r_i].

Special Property A: It is guaranteed that for all i[1,m]i \in [1,m], rili+15r_i-l_i+1\le 5.

Special Property B: It is guaranteed that the intersections of these intervals are all 1\le 1. That is, for all i,j[1,m]i,j \in [1,m] with iji\ne j, we have riljr_i\le l_j or rjlir_j\le l_i.

Special Property C: It is guaranteed that these intervals have no containment relationship. That is, for all i,j[1,m]i,j \in [1,m] with iji\ne j, we have li>ljl_i>l_j or ri<rjr_i<r_j.

For 100%100\% of the data, 1n,k1051 \le n,k \le 10^5, 0m1050 \le m \le 10^5, 1piqi<109+71 \le p_{i} \le q_{i} \lt 10^{9}+7, 0li<rin0 \le l_{i} \lt r_{i} \le n.

Translated by ChatGPT 5