QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 1024 MB Total points: 100

#6171. 序列区间段查询问题

Statistics

序列区间段查询问题:给出一个长度为 $n$ 的序列 $a$ 。$q$ 次询问,每次给定 $l,r,k$,求有多少个数对 $(l',r')$ 满足 $l \leq l' \leq r' \leq r$,使得 $\operatorname{mex}(\{a_{l'},a_{l'+1},...,a_{r'}\})=k$。

输入格式

输入的第一行包含两个整数 $n,q$。

接下来一行,包含 $n$ 个数,表示序列 $a$ 。

接下来 $q$ 行,每行三个整数 $l,r,k$。

输出格式

对于每组询问,输出一行一个整数,表示答案。

样例数据

样例输入

10 10
0 0 4 1 1 3 0 4 6 1
2 2 1
4 10 2
1 4 0
4 8 0
4 4 1
1 6 0
5 8 0
2 10 3
3 9 6
1 4 0

样例输出

1
10
3
7
0
10
4
0
0
3

子任务

对于 $10\%$ 的数据,$n,q \leq 1\,000$。

对于 $100\%$ 的数据,$1 \leq n,q \leq 230\,000$,$0 \leq a_i, k \leq 10^9$。


  1. 赛时并未提供空间限制,“请选手自行评估” QOJ 上设置为 1 GB。
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.