QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 250 MB Total points: 100

#7468. 成都七中

统计

题目描述

给你一棵 $n$ 个节点的树,每个节点有一种颜色,有 $m$ 次查询操作。

查询操作给定参数 $l\ r\ x$,需输出:

将树中编号在 $[l,r]$ 内的所有节点保留,$x$ 所在连通块中颜色种类数。

每次查询操作独立。

输入格式

第一行两个数 $n,m$。

第二行 $n$ 个数表示每个节点的颜色。

之后 $n-1$ 行,每行两个数 $x$ 和 $y$,表示 $x$ 和 $y$ 之间连有一条边。

之后 $m$ 行,每行三个数 $l\ r\ x$,表示一次查询操作。

输出格式

对每个查询操作,输出一行一个数表示答案。

样例 #1

样例输入 #1

5 4
1 3 5 3 5
1 2
2 3
3 4
4 5
1 5 1
2 4 3
3 4 3
1 4 3

样例输出 #1

3
2
2
3

提示

Idea:nzhtl1477,Solution:nzhtl1477,Code:created_equal1,Data:nzhtl1477

对于 $100\%$ 的数据,所有出现过的数在 $[1,10^5]$ 之间,保证每次输入的 $l \le x \le r$。

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.