QOJ.ac

QOJ

Time Limit: 0.6 s Memory Limit: 24 MB Total points: 100

#7486. 等这场战争结束之后

统计

给你一个图,每个点有点权,最开始没有边。

有一些操作:

  1. 添加一条 $x$ 与 $y$ 之间的双向边。
  2. 回到第 $x$ 次操作后的状态(注意这里的 $x$ 可以是 $0$,即回到初始状态)。
  3. 查询 $x$ 所在联通块能到的点中点权第 $y$ 小的值,如果不存在,那么输出 $-1$。

输入格式

第一行输入两个整数 $n,m$,表示有 $n$ 个点,$m$ 个操作。

之后一行 $n$ 个数,表示每个点的点权。

之后 $m$ 行,每行有三种可能的操作:

1 x y

2 x

3 x y

意义见题面。

输出格式

对所有 $3$ 的操作,输出一行,包含一个整数,表示答案。

样例数据

样例输入

6 10
816801151 223885531 110182151 94271893 319888699 106363731 
1 1 3
1 3 5
1 2 4
1 4 6
1 1 2
3 1 1
2 4
1 1 2
3 1 4
2 7

样例输出

94271893
223885531

子任务

Idea:nzhtl1477,

Solution:nzhtl1477( $O( nm/w )$ Time , $O( n\log n )$ Space ),ccz181078( $O( m\sqrt{n\log n} )$ Time ,$O(n\sqrt{n\log n} )$ Space ) ,shadowice1984( $O( m\sqrt{n\log n} )$ Time , $O( n\log n )$ Space ) , zx2003( $O( m\sqrt{n} )$ Time ,$O( n )$ Space )

Code:nzhtl1477( $O( nm/w )$ Time , $O( n\log n )$ Space ),ccz181078( $O( m\sqrt{n\log n} )$ Time , $O( n\sqrt{n\log n} )$ Space ) ,shadowice1984( $O( m\sqrt{n\log n} )$ Time ,$O( n\log n )$ Space ),zx2003( $O( m\sqrt{n} )$ Time ,$O( n )$ Space )

Data:nzhtl1477( partially uploaded )

对于 $100\%$ 的数据,$1\leq n,m\leq 10^5$,$0\leq a_i\leq 10^9$。

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.