这是我想要解决的问题,我使用The Fact That Prefix Sum[i] - Prefix Sum[i-1]导致频率大于零来识别不同的数字然后我正在消除频率,但即使有BIT,我也得到了一个TLE
给定n个数字序列a1,a2,...,an和许多d查询.
d查询是一对(i,j)(1≤i≤j≤n).
对于每个d查询(i,j),您必须返回子序列ai,ai + 1,...,aj中的不同元素的数量.
Input
Line 1: n (1 ? n ? 30000).
Line 2: n numbers a1, a2, ..., an (1 ? ai ? 106).
Line 3: q (1 ? q ? 200000), the number of d-queries.
In the next q lines, each line contains 2 numbers i, j
representing a d-query (1 ? i ? j ? n).
Output
For each d-query (i, j), print the number …Run Code Online (Sandbox Code Playgroud)