#P12151. 【MX-X11-T5】「蓬莱人形 Round 1」俄罗斯方块

【MX-X11-T5】「蓬莱人形 Round 1」俄罗斯方块

Description

Given an integer sequence hih_i of length nn, along with nn pairs (ai,bi)(a_i, b_i) and a positive integer kk.

For each position pp, you can perform one of the following operations:

  • Activate position pp: Choose a position jj satisfying 1jpk1 \le j - p \le k, then update hphp+aph_p \leftarrow h_p + a_p and hjhjbph_j \leftarrow h_j - b_p. Each position can be activated at most once.
  • Do not activate position pp.

There are qq queries (li,ri,xi)(l_i, r_i, x_i). For each query, under the constraints that only positions p[li,ri]p \in [l_i, r_i] can be activated and the corresponding jj must lie within [p+1,min(p+k,ri)][p+1, \min(p+k, r_i)], determine whether there exists a way to activate positions such that maxt=lirihtxi\max_{t=l_i}^{r_i} h_t \le x_i.

Queries are independent: the sequence hh is restored to its original state at the start of each query, and no activation choices are retained between queries.

Input Format

Multiple test cases.
The first line contains two integers cc and TT, representing the subtask number and the number of test cases, respectively. Sample inputs satisfy c=0c=0.

For each test case:

  • The first line contains three integers n,q,kn, q, k, representing the sequence length, number of queries, and activation range parameter.
  • The second line contains nn integers h1,h2,,hnh_1, h_2, \ldots, h_n.
  • The third line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n.
  • The fourth line contains nn integers b1,b2,,bnb_1, b_2, \ldots, b_n.
  • The next qq lines each contain three integers li,ri,xil_i, r_i, x_i, describing the ii-th query.

Output Format

For each query, output Yes or No indicating whether a valid activation scheme exists.

0 1
3 2 1
2 0 2
4 1 1
0 8 0
2 3 1
1 3 1
Yes
No
0 2
7 7 3
4 1 2 2 3 2 2
4 1 4 0 3 2 1
3 3 4 1 3 3 0
5 5 4
3 4 5
1 4 3
2 5 0
1 2 3
1 4 5
1 3 4
7 7 3
5 2 1 5 2 5 2
4 2 1 4 3 1 2
1 5 3 4 1 5 1
6 7 5
1 4 5
2 4 5
5 7 5
1 2 5
3 4 5
2 6 5
Yes
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes

Hint

Explanation #1

Sample 1 Explanation:

For the query (2,3,1)(2, 3, 1), activating position 22 updates h2h_2 to 0+a2=10 + a_2 = 1 and h3h_3 to 2b2=28=62 - b_2 = 2 - 8 = -6. The maximum value in [2,3][2, 3] is 11, satisfying the condition.

For the query (1,3,1)(1, 3, 1), no valid activation exists.

Constraints

This problem uses subtask scoring.

For all test data: 1T31 \le T \le 3, 1n2×1041 \le n \le 2 \times 10^4, 1q1051 \le q \le 10^5, 0hi,ai,bi,xi1060 \le h_i, a_i, b_i, x_i \le 10^6, 1lirin1 \le l_i \le r_i \le n, 1k51 \le k \le 5.

Subtask nn \le qq \le kk \le TT \le Special Property Points Time Limit
1 10 5 3 None 5 1 s
2 1000 1 10
3 2×1042 \times 10^4 10510^5 3 A 4 s
4 10410^4 3 1 B 5 1 s
5 None 10
6 2×1042 \times 10^4 2×1042 \times 10^4 4 B 5
7 None 10
8 4×1044 \times 10^4 2 B 5
9 None 10
10 10510^5 5 3 30 4 s
  • Special Property A: For all queries, li=1l_i = 1 and ri=nr_i = n.
  • Special Property B: For all queries, xi=xjx_i = x_j for any i,ji, j.

Note: Be mindful of the problem's time limits.

Translated by DeepSeek R1