QOJ.ac

QOJ

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

#15390. 有马加奈

統計

对于一个节点 $i$ 存在二元组信息 $(a_i,b_i)$。

给定大小为 $n$ 的树。初始化所有节点全为 $(0,0)$。根为 $1$。

给定 $m$ 个操作。

  • $1 \ x \ c$ 设当前操作编号为 $z$,对于 $x$ 到根路径,路径上的所有节点 $i$ 的二元组信息,若 $a_i = c$ 那么令 $(a_i,b_i) \leftarrow (c,b_i)$ 否则令 $(a_i,b_i) \leftarrow (c,z)$。
  • $2 \ x$ 查询 $(a_x,b_x)$。

输入格式

第一行两个整数 $n,m$ 代表树的大小和操作个数。

接下来一行 $n - 1$ 个数,第 $i$ 个数 $p_i$ 表示点 $i + 1$ 的父亲 $p_i$。

接下来 $m$ 行,每行三个数或两个数代表操作。

输出格式

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

样例数据

样例 1 输入

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

样例 1 输出

0 0
0 0
3 2
3 2

子任务

Idea: FutaRimeWoawaSete,Solution: FutaRimeWoawaSete,Code: FutaRimeWoawaSete,Data: FutaRimeWoawaSete

测试点 $n$ $m$ 特殊性质
$1 \sim 5$ $\leq \times 10 ^ 5$ $\leq 10 ^ 5$ $A$
$6 \sim 10$ $\leq 10 ^ 5$ $B$
$11 \sim 15$ $C$
$16 \sim 20$ $\le 10^6$ $\leq 10 ^ 6$ $/$

特殊性质 $A$:满足 $p_i$ 从 $[1,i - 1]$ 里随机选择。

特殊性质 $B$:保证所有 $1$ 操作中 $c = 1$。

特殊性质 $C$:保证 $p_i = i - 1$。

所有数据保证 $n,q \leq 10 ^ 6,x,c \in [1,n]$。

保证样例 $2,3,4,5$ 相应性质对应测试点 $1 \sim 5,6 \sim 10,11 \sim 15,16 \sim 20$ 且使用同一构造方式生成。

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.