CF622C.Not Equal on a Segment
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given array a with n integers and m queries. The i-th query is given with three integers l__i, r__i, x__i.
For the i-th query find any position p__i (l__i ≤ p__i ≤ r__i) so that a__p__i ≠ x__i.
给你一个包含 n 个整数的数组 a,以及 m 个查询。第 i 个查询由三个整数 li,ri,xi 给出。
对于第 i 个查询,请在区间 [li,ri] 内找出任意一个位置 pi(即满足 li≤pi≤ri),使得 api=xi。
输入格式
The first line contains two integers n, m (1 ≤ n, m ≤ 2·105) — the number of elements in a and the number of queries.
The second line contains n integers a__i (1 ≤ a__i ≤ 106) — the elements of the array a.
Each of the next m lines contains three integers l__i, r__i, x__i (1 ≤ l__i ≤ r__i ≤ n, 1 ≤ x__i ≤ 106) — the parameters of the i-th query.
第一行包含两个整数 n、m(1≤n,m≤2⋅105)—— 分别表示数组 a 的元素个数和查询次数。
第二行包含 n 个整数 ai(1≤ai≤106)—— 表示数组 a 的元素。
接下来的 m 行,每行包含三个整数 li、ri、xi(1≤li≤ri≤n,1≤xi≤106)—— 表示第 i 个查询的参数。
输出格式
Print m lines. On the i-th line print integer p__i — the position of any number not equal to x__i in segment [l__i, r__i] or the value - 1 if there is no such number.
输出 m 行。在第 i 行输出整数 p__i —— 即区间 [l__i, r__i] 中任意一个不等于 x__i 的数的位置;若不存在这样的数,则输出 - 1。
输入输出样例
输入#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
输入解题思路,AI测评打分。不知道怎么写?