QOJ.ac

QOJ

Time Limit: 4 s Memory Limit: 512 MB Total points: 100

#14732. stdmxeypz

Statistics

给你一棵边权为 $1$,且以 $1$ 为根的有根树,每个点有初始为 $0$ 的点权值,定义两个点的距离为其在树上构成的简单路径的长度,需要支持两种操作:

1 a x y z:把 $a$ 子树中所有与 $a$ 的距离模 $x$ 等于 $y$ 的节点权值加 $z$。

2 a:查询 $a$ 节点的权值。

输入格式

第一行两个整数 $n,m$ 表示树的节点数为 $n$,有 $m$ 次操作。

第二行 $n-1$ 个整数,第 $i$ 个数 $f_i$ 表示树上第 $i+1$ 个节点的父亲节点。

之后 $m$ 行,每行形如 1 a x y z2 a,表示上述的操作。

输出格式

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

样例数据

样例 1 输入

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

样例 1 输出

5
0

子任务

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

对于 $100\%$ 的数据,满足 $1\leq n , m\leq 3\times 10^5$,$1\leq f_i\leq i$,$1\leq a\leq n$,$1\leq x\leq n$,$0\leq y < x$,$0 \leq z < 514$。

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.