QOJ.ac

QOJ

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

#7471. ODT

الإحصائيات

题目描述

给你一棵树,边权为 $1$,有点权。

需要支持两个操作:

  • 1 x y z:表示把树上 $x$ 到 $y$ 这条简单路径的所有点点权都加上 $z$。
  • 2 x y:表示查询与点 $x$ 距离小于等于 $1$ 的所有点里面的第 $y$ 小点权。

输入格式

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

第二行 $n$ 个整数表示每个点的点权。

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

之后 $m$ 行,每行为 1 x y z 或者 2 x y 形式,意义如上述。

输出格式

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

数据保证每次询问都存在答案。

样例 #1

样例输入 #1

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

样例输出 #1

4
3
4

提示

Idea:nzhtl1477,

Solution:nzhtl1477( $O( n\log^2n/ \log\log n )$ solution ),negiizhao( $O( n\log n\log\log\log n )$ solution ),ccz181078( $O( n\log n )$ solution ),

Code:nzhtl1477( $O( n\log^2 n/ \log\log n )$ code )

Data:nzhtl1477( partially uploaded )

subtask 1:$20\%$ $n,m\leq 1000$。

subtask 2:$10\%$ 树为一条链。

subtask 3:$20\%$ $n,m\leq 10^5$。

subtask 4:$30\%$ $n,m\leq 4\times 10^5$。

subtask 5:$20\%$ $n,m\leq 10^6$。

对于 $100\%$ 的数据,$1\leq n,m\leq 10^6$,$0\leq $ 每次加的数 $\leq 2000$,$0\leq $ 初始的点权 $\leq 2000$。

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.