QOJ.ac

QOJ

Time Limit: 8 s Memory Limit: 2048 MB Total points: 100

#11282. SMV CC-64“蝰蛇”

الإحصائيات

给序列 $a_1,\dots,a_n$ 和排列 $b_1,\dots,b_n$,共有 $m$ 次操作:

修改操作:给定 $x,y$,将 $a_x$ 改为 $y$;

查询操作:给定 $l,r,x$,查区间 $[l,r]$ 内最长的子区间 $[l',r']$(即满足 $l\le l'\le r'\le r$),使得对 $l'\le i< r'$ 有 $a_{i+1}=b_{a_i}$,且存在 $l'\le i\le r'$ 使得 $a_i=x$。需要输出满足条件的 $r'-l'+1$ 的最大值,若不存在则输出 $0$。

输入格式

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

第二行 $n$ 个整数依次表示 $a_1,\dots,a_n$;

第三行 $n$ 个整数依次表示 $b_1,\dots,b_n$;

接下来 $m$ 行,每行 $1,x,y$ 或 $2,l,r,x$ 表示进行一次修改操作或查询操作。

输入的所有数值为整数。

输出格式

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

样例数据

样例输入

8 10
1 4 7 3 8 2 4 7
5 4 8 7 1 6 3 2
2 6 6 2
2 8 8 7
1 4 3
2 6 8 3
2 4 4 3
2 4 4 3
2 6 8 4
2 5 6 2
2 1 8 1
2 1 1 6

样例输出

1
1
0
1
1
3
2
1
0

子任务

Idea:s_r_f,Solution:ccz181078,Code:ccz181078,Data:ccz181078

对于 $100\%$ 的数据,满足:

$1\le n,m\le 10^6$;

$1\le a_i\le n$;

$1\le b_i\le n$,$b_i$ 互不相同;

对修改操作,满足 $1\le x,y\le n$;

对查询操作,满足 $1\le l\le r\le n$,$1\le x\le n$。

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.