CF551E.GukiZ and GukiZiana

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Professor GukiZ was playing with arrays again and accidentally discovered new function, which he called GukiZianaGukiZiana . For given array aa , indexed with integers from 11 to nn , and number yy , GukiZiana(a,y)GukiZiana(a,y) represents maximum value of jij-i , such that aj=ai=ya_{j}=a_{i}=y . If there is no yy as an element in aa , then GukiZiana(a,y)GukiZiana(a,y) is equal to 1-1 . GukiZ also prepared a problem for you. This time, you have two types of queries:

  1. First type has form 11 ll rr xx and asks you to increase values of all aia_{i} such that l<=i<=rl<=i<=r by the non-negative integer xx .
  2. Second type has form 22 yy and asks you to find value of GukiZiana(a,y)GukiZiana(a,y) .

For each query of type 22 , print the answer and make GukiZ happy!

输入格式

The first line contains two integers nn , qq ( 1<=n<=5105,1<=q<=51041<=n<=5*10^{5},1<=q<=5*10^{4} ), size of array aa , and the number of queries.

The second line contains nn integers a1,a2,... ana_{1},a_{2},...\ a_{n} ( 1<=ai<=1091<=a_{i}<=10^{9} ), forming an array aa .

Each of next qq lines contain either four or two numbers, as described in statement:

If line starts with 11 , then the query looks like 11 ll rr xx ( 1<=l<=r<=n1<=l<=r<=n , 0<=x<=1090<=x<=10^{9} ), first type query.

If line starts with 22 , then th query looks like 22 yy ( 1<=y<=1091<=y<=10^{9} ), second type query.

输出格式

For each query of type 22 , print the value of GukiZiana(a,y)GukiZiana(a,y) , for yy value for that query.

输入输出样例

  • 输入#1

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

    输出#1

    2
    
  • 输入#2

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

    输出#2

    0
    -1
    
首页