#P8936. [JRKSJ R7] 月下缭乱

    ID: 9849 远端评测题 1500ms 256MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>线段树并查集2023颜色段均摊(珂朵莉树 ODT)洛谷原创O2优化

[JRKSJ R7] 月下缭乱

Background

The light and lively music strengthens your determination to solve an easy problem.

(The background image comes from a Phigros song illustration. If there is any infringement, please inform the problem setter.)

Problem Description

You have a sequence aa of length nn, with all initial values equal to 00.

You have an operation sequence of length mm. The ii-th operation has three parameters li,ri,xil_i, r_i, x_i, meaning that for all j[li,ri]j \in [l_i, r_i], set ajmax(aj,xi)a_j \gets \max(a_j, x_i).

Let sol(l,r)\text{sol}(l,r) denote the sequence aa after applying operations ll through rr in order.

You need to answer how many pairs (l,r)(l,r) satisfy 1lrm1 \le l \le r \le m and sol(l,r)=sol(1,m)\text{sol}(l,r) = \text{sol}(1,m).

Let fif_i be the number of kk with ikmi \le k \le m such that sol(i,k)=sol(1,m)\text{sol}(i,k) = \text{sol}(1,m). You also need to output the values of i=1mfi×i\displaystyle\bigoplus_{i=1}^m f_i \times i and i=1mfi×i\displaystyle\sum_{i=1}^m f_i \times i.

All answers should be output modulo 2322^{32}.

Input Format

The first line contains two integers n,mn, m.

The next mm lines each contain three integers li,ri,xil_i, r_i, x_i, describing the ii-th operation.

Output Format

Output three integers in one line, representing the answers modulo 2322^{32}.

5 5
1 3 1
2 4 1
2 3 1
1 3 1
1 4 1

9 2 20
3 5
1 3 2
1 1 1
2 2 2
3 3 3
1 3 2

5 7 11

Hint

Idea: cyffff, Solution: Ntokisq / abruce, Code: cyffff, Data: cyffff.

Moonlit Dazzle - Tsukimi Shizuka vs. LUNARiUM (Insane14.8)

The input and output files for this problem are large, so please use appropriate I/O methods.

Sample Explanation

For sample 22, the final sequence aa is {2,2,3}\{2,2,3\}. It is easy to see that applying the operations in [1,4][1,4], [1,5][1,5], [2,5][2,5], [3,5][3,5], and [4,5][4,5] can all make aa the same as the sequence after applying all operations. The answer is 55. The sequence ff is {2,1,1,1,0}\{2,1,1,1,0\}.

Constraints

This problem uses bundled testdata.

::cute-table | Subtask\text{Subtask} | n,mn,m\le | Special Constraints | Score\text{Score} | | :----------: | :----------: | :----------: | :----------: | | 11 | 100100 | None | 1010 | | 22 | 10410^4 | ^ | 2020 | | 33 | 3×1053\times10^5 | Guaranteed li=ril_i=r_i | 1010 | | 44 | ^ | Guaranteed xi=1x_i=1 | 1010 | | 55 | ^ | None | 2020 | | 66 | 10610^6 | ^ | 3030 |

For 100%100\% of the testdata, 1n,m1061 \le n,m \le 10^6, 1lirin1 \le l_i \le r_i \le n, 1xim1 \le x_i \le m.

Special Scoring

This problem enables subtask dependencies, as follows.

  • For subtask i{1,3,4}i \in \{1,3,4\}, you only need to solve subtask ii correctly to get the score of subtask ii.
  • For subtask i{2,5,6}i \in \{2,5,6\}, you need to solve all subtasks j[1,i]j \in [1,i] correctly to get the score of subtask ii.

Translated by ChatGPT 5