#P11103. [ROI 2022] 挑战 (Day 2)

[ROI 2022] 挑战 (Day 2)

Background

Translated from ROI 2022 D2T4.

In the design class at the Sirius Educational Center, a team designed an industrial robot. These robots will put parts into nn containers numbered from 11 to nn. Each container can hold at most aia_i parts.

There are mm robots in total. Initially, robot jj has cjc_j parts. Also, robot jj has a working range determined by two numbers ljl_j and rjr_j, meaning it can only put parts into containers with indices from ljl_j to rjr_j (inclusive). Robots try to put as many parts as possible into the containers.

Robots are of two types. If a robot has type tj=0t_j = 0, then its working range always stays unchanged. If a robot has type tj=1t_j = 1, it can change its working range. If the container numbered xx is designated as the most important container, then the working range of every type 11 robot will expand so that this range contains container xx. In other words, for a type 11 robot jj, its working range will become [min(lj,x),max(rj,x)][\min(l_j,x),\max(r_j,x)].

Problem Description

For each xx from 11 to nn, compute the maximum number of parts that the robots can put into the containers when container xx is considered the most important container.

Input Format

This problem has multiple test cases. The first line contains an integer tt, the number of test cases.

For each test case, the first line contains two integers nn and mm, the number of containers and the number of robots.

The next line contains nn integers a1,a2,,ana_1,a_2,\dots,a_n, the capacities of the containers.

Each of the next mm lines contains four integers lj,rj,cj,tjl_j, r_j, c_j, t_j, describing the robot's working range, the number of parts it initially carries, and the robot type.

Output Format

For each test case, output nn integers, representing the answers for all xx from 11 to nn.

1
4 3
3 3 2 2
1 2 2 0
3 3 3 0
2 2 4 1
8 7 7 8

Hint

For 100%100\% of the testdata, 1t2000001 \le t \le 200000, 1n,m2000001 \le n,m \le 200000, 0ai1090 \le a_i \le 10^9, 1ljrjn1 \le l_j \le r_j \le n, 0cj1090 \le c_j \le 10^9, tj{0,1}t_j \in \{0, 1\}.

Subtask Score n\sum n\le m\sum m\le Other special properties
11 1010 100100 m=1m=1
22 77
33 66 20002000
44 2000020000 200200
55 1212 10510^5 20002000
66 1717 2000020000 ti=1t_i=1
77 88 10510^5 lili+1,riri+1,ti=1l_i\le l_{i+1},r_i\le r_{i+1},t_i=1
88 ti=1t_i=1
99 1313 For all robots with ti=0t_i=0, ri50r_i\le50 or li>n50l_i>n-50
1010 44 ai=1a_i=1
1111 66
1212 33 2×1052\times10^5

Translated by ChatGPT 5