#P15871. 【MX-X26-T7】「Cfz Round 7」**终极 AVX2 硬件指令提速**

【MX-X26-T7】「Cfz Round 7」**终极 AVX2 硬件指令提速**

Problem Description

Given an array vv of length nn and a 2D plane containing nn "fish", the coordinates of the ii-th "fish" are (xi,yi)(x_i, y_i), with a weight interval [li,ri][l_i, r_i].

There are mm queries. Each query provides Ai,Bi,CiA_i, B_i, C_i. Define f(k,Ai,Bi,Ci)=1f(k, A_i, B_i, C_i) = 1 if and only if Aixk+Biyk+Ci<0A_i x_k + B_i y_k + C_i < 0; otherwise, f(k,Ai,Bi,Ci)=0f(k, A_i, B_i, C_i) = 0. Define the set SS as the set of all integers that lie in the union of [lk,rk][l_k, r_k] over all kk satisfying f(k,Ai,Bi,Ci)=1f(k, A_i, B_i, C_i) = 1. Compute ∑k∈Svk\sum_{k \in S} v_k.

Input Format

The first line contains an integer cc, indicating the subtask ID of this test point. The samples satisfy c=0c = 0.

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

The next nn lines: the ii-th line contains four integers xi,yi,li,rix_i, y_i, l_i, r_i.

The next line contains nn integers v1,…,vnv_1, \dots, v_n.

The next mm lines: the ii-th line contains three integers Ai,Bi,CiA_i, B_i, C_i.

Output Format

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

0
5 2
2 2 4 4
-3 -3 1 1
-3 -1 3 5
1 -1 3 3
-2 3 1 5
12 3955 8019 1664 9231
2 -2 1
3 2 1
22881
18926

Hint

Sample 1 Explanation

For the 11-st query, only the 33-rd "fish" and the 55-th "fish" satisfy the condition. Their weight intervals are [3,5][3, 5] and [1,5][1, 5], so S={1,2,3,4,5}S = \{1, 2, 3, 4, 5\}. The answer is v1+v2+v3+v4+v5=22881v_1 + v_2 + v_3 + v_4 + v_5 = 22881.

For the 22-nd query, only the 22-nd "fish" and the 33-rd "fish" satisfy the condition. Their weight intervals are [1,1][1, 1] and [3,5][3, 5], so S={1,3,4,5}S = \{1, 3, 4, 5\}. The answer is v1+v3+v4+v5=18926v_1 + v_3 + v_4 + v_5 = 18926.

Constraints

For all testdata:

  • 1≤n≤5⋅1041 \le n \le 5 \cdot 10^4, 1≤m≤5⋅1051 \le m \le 5 \cdot 10^5.
  • For all 1≤i≤n1 \le i \le n: −106≤xi,yi≤106-10^6 \le x_i, y_i \le 10^6, 1≤li≤ri≤n1 \le l_i \le r_i \le n.
  • For all 1≤i≤n1 \le i \le n: 1≤vi≤1041 \le v_i \le 10^4.
  • For all 1≤i≤m1 \le i \le m: −103≤Ai,Bi≤103-10^3 \le A_i, B_i \le 10^3, Ai2+Bi2>0{A_i}^2 + {B_i}^2 > 0, 1≤Ci≤1091 \le C_i \le 10^9.

For testdata other than Subtask 2, it is guaranteed that the x,yx, y coordinates of the nn "fish" are independently and uniformly randomly chosen within some preset ranges. Also, for the ii-th "fish", li,ril_i, r_i and xi,yix_i, y_i are independently randomly chosen, but the distribution of li,ril_i, r_i has no special restriction.

This problem uses bundled evaluation.

  • Subtask 1 (10 points): n,m≤103n, m \le 10^3.
  • Subtask 2 (18 points): For all 1≤i≤n1 \le i \le n, it is guaranteed that max⁡(∣xi∣,∣yi∣)=106\max(|x_i|, |y_i|) = 10^6.
  • Subtask 3 (18 points): For all 1≤i≤m1 \le i \le m, it is guaranteed that ∣Ai∣=∣Bi∣=1|A_i| = |B_i| = 1.
  • Subtask 4 (24 points): n≤2⋅104n \le 2 \cdot 10^4, m≤2⋅105m \le 2 \cdot 10^5.
  • Subtask 5 (30 points): No special restrictions.

Translated by ChatGPT 5