#P10288. [GESP样题 八级] 区间

[GESP样题 八级] 区间

Background

Related multiple-choice and true/false problems: https://ti.luogu.com.cn/problemset/1108.

Problem Description

Xiao Yang has a positive integer sequence AA of length nn.

Xiao Yang has qq queries. In the ii-th query (1iq1 \le i \le q), Xiao Yang gives li,ri,xil_i, r_i, x_i. Please find how many times xix_i appears in Ali,Ali+1,,AriA_{l_i}, A_{l_i+1}, \dots, A_{r_i}.

Input Format

The first line contains a positive integer TT, indicating the number of test cases.

For each test case: the first line contains a positive integer nn, indicating the length of sequence AA.
The second line contains nn positive integers A1,A2,,AnA_1, A_2, \dots, A_n, representing the sequence AA.
The third line contains a positive integer qq, indicating the number of queries. The next qq lines each contain three positive integers li,ri,xil_i, r_i, x_i, representing one query.

Output Format

For each test case, output qq lines. On the ii-th line (1iq1 \le i \le q), output a non-negative integer representing the answer to the ii-th query.

2
5
7 4 6 1 1
2
1 2 3
1 5 1
5
1 2 3 4 5
2
5 5 3
1 4 3
0
2
0
1

Hint

Constraints

Subtask Points nn qq maxAi\max A_i
11 3030 100\le 100 10\le 10
22 105\le 10^5 105\le 10^5
33 4040 109\le 10^9

For all testdata, it is guaranteed that 1T51 \le T \le 5, 1n,q1051 \le n, q \le 10^5, and 1Ai1091 \le A_i \le 10^9.

Translated by ChatGPT 5