CF622C.Not Equal on a Segment

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You are given array aa with nn integers and mm queries. The ii -th query is given with three integers li,ri,xil_{i},r_{i},x_{i} .

For the ii -th query find any position pip_{i} ( li<=pi<=ril_{i}<=p_{i}<=r_{i} ) so that apixia_{pi}≠x_{i} .

输入格式

The first line contains two integers n,mn,m ( 1<=n,m<=21051<=n,m<=2·10^{5} ) — the number of elements in aa and the number of queries.

The second line contains nn integers aia_{i} ( 1<=ai<=1061<=a_{i}<=10^{6} ) — the elements of the array aa .

Each of the next mm lines contains three integers li,ri,xil_{i},r_{i},x_{i} ( 1<=li<=ri<=n,1<=xi<=1061<=l_{i}<=r_{i}<=n,1<=x_{i}<=10^{6} ) — the parameters of the ii -th query.

输出格式

Print mm lines. On the ii -th line print integer pip_{i} — the position of any number not equal to xix_{i} in segment [li,ri][l_{i},r_{i}] or the value 1-1 if there is no such number.

输入输出样例

  • 输入#1

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

    输出#1

    2
    6
    -1
    4
    
首页