#P4560. [IOI 2014] Wall 砖墙

[IOI 2014] Wall 砖墙

Description

You are given a sequence of length nn with all initial values equal to 00. You need to support the following two operations:

  • Add L,R,hL, R, h: For all elements in [L,R][L, R] that are less than hh, set them to hh. Do not change elements whose height is greater than hh.
  • Remove L,R,hL, R, h: For all elements in [L,R][L, R] that are greater than hh, set them to hh. Do not change elements whose height is less than hh.

You need to output the sequence after performing kk operations.

Input Format

The first line contains two positive integers n,kn, k, representing the number of elements in the sequence and the number of operations. Note: indices are numbered from 00 to n1n - 1.

Each of the next kk lines contains 44 integers t,L,R,ht, L, R, h. If t=1t = 1, it denotes an Add operation; if t=2t = 2, it denotes a Remove operation. The meanings of L,R,hL, R, h are as described above.

Output Format

Output nn lines. The integer on the ii-th line is the value of the element with index i1i - 1 after all kk operations.

10 3
1 3 4 91220
1 5 9 48623
2 3 5 39412

0
0
0
39412
39412
39412
48623
48623
48623
48623

10 6
1 1 8 4
2 4 9 1
2 3 6 5
1 0 5 3
1 2 2 5
2 6 7 0

3
4
5
4
3
3
0
0
1
0

Hint

  • Subtask #1 (8 points): 1n100001 \leq n \leq 10\,000, 1k50001 \leq k \leq 5\,000.
  • Subtask #2 (24 points): 1n1000001 \leq n \leq 100\,000, 1k5000001 \leq k \leq 500\,000, all Add operations appear before all Remove operations.
  • Subtask #3 (29 points): 1n1000001 \leq n \leq 100\,000, 1k5000001 \leq k \leq 500\,000.
  • Subtask #4 (39 points): 1n20000001 \leq n \leq 2\,000\,000, 1k5000001 \leq k \leq 500\,000.

Constraints: For all operations, the height hh satisfies 0h1000000 \leq h \leq 100\,000.

Translated by ChatGPT 5