CF811B.Vladik and Complicated Book

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Vladik had started reading a complicated book about algorithms containing n pages. To improve understanding of what is written, his friends advised him to read pages in some order given by permutation P = [_p_1, _p_2, ..., p__n], where p__i denotes the number of page that should be read i-th in turn.

Sometimes Vladik’s mom sorted some subsegment of permutation P from position l to position r inclusive, because she loves the order. For every of such sorting Vladik knows number x — what index of page in permutation he should read. He is wondered if the page, which he will read after sorting, has changed. In other words, has p__x changed? After every sorting Vladik return permutation to initial state, so you can assume that each sorting is independent from each other.

弗拉迪克开始阅读一本关于算法的复杂书籍,该书共有 nn 页。为了加深对书中内容的理解,他的朋友们建议他按照某个由排列 P=[p1,p2,…,pn]P = [p_1, p_2, \dots, p_n] 给出的顺序来阅读,其中 pip_i 表示第 ii 个应被阅读的页码。

有时,弗拉迪克的妈妈会将排列 PP 中从位置 ll 到位置 rr(包含端点)的某个子段进行升序排序,因为她喜欢有序。对于每一次这样的排序操作,弗拉迪克都知道一个数 xx —— 即他在排序后应当阅读的页码在排列中的索引(即排序后他要读的是第 xx 个位置上的页码)。他很好奇:经过此次排序后,他将要阅读的页码是否发生了变化?换言之,pxp_x 的值是否发生了改变?每次排序结束后,弗拉迪克都会将排列恢复为初始状态,因此你可以认为每次排序操作都是相互独立的。

输入格式

First line contains two space-separated integers n, m (1 ≤ n, m ≤ 104) — length of permutation and number of times Vladik's mom sorted some subsegment of the book.

Second line contains n space-separated integers _p_1, _p_2, ..., p__n (1 ≤ p__i ≤ n) — permutation P. Note that elements in permutation are distinct.

Each of the next m lines contains three space-separated integers l__i, r__i, x__i (1 ≤ l__i ≤ x__i ≤ r__i ≤ n) — left and right borders of sorted subsegment in i-th sorting and position that is interesting to Vladik.

第一行包含两个用空格分隔的整数 nn、mm(1≤n,m≤1041 \leq n, m \leq 10^4)—— 分别表示排列的长度以及弗拉迪克(Vladik)妈妈对书中某子段进行排序的次数。

第二行包含 nn 个用空格分隔的整数 p1,p2,…,pnp_1, p_2, \dots, p_n(1≤pi≤n1 \leq p_i \leq n)—— 排列 PP。注意:排列中的元素互不相同。

接下来的 mm 行中,每行包含三个用空格分隔的整数 li,ri,xil_i, r_i, x_i(1≤li≤xi≤ri≤n1 \leq l_i \leq x_i \leq r_i \leq n)—— 分别表示第 ii 次排序操作所作用子段的左右边界,以及弗拉迪克感兴趣的下标位置。

输出格式

For each mom’s sorting on it’s own line print "Yes", if page which is interesting to Vladik hasn't changed, or "No" otherwise.

对于每位母亲的排序,若 Vladik 感兴趣的页面未发生变化,则在单独一行输出“Yes”;否则输出“No”。

输入输出样例

  • 输入#1

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

    输出#1

    Yes
    No
    Yes
    Yes
    No
  • 输入#2

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

    输出#2

    Yes
    No
    Yes
    No
    Yes

说明/提示

Explanation of first test case:

  1. [1, 2, 3, 4, 5] — permutation after sorting, 3-rd element hasn’t changed, so answer is "Yes".
  2. [3, 4, 5, 2, 1] — permutation after sorting, 1-st element has changed, so answer is "No".
  3. [5, 2, 3, 4, 1] — permutation after sorting, 3-rd element hasn’t changed, so answer is "Yes".
  4. [5, 4, 3, 2, 1] — permutation after sorting, 4-th element hasn’t changed, so answer is "Yes".
  5. [5, 1, 2, 3, 4] — permutation after sorting, 3-rd element has changed, so answer is "No".

第一个测试用例的解释:

  1. [1, 2, 3, 4, 5] — 排序后的排列,第 3 个元素未发生变化,因此答案为 “Yes”。
  2. [3, 4, 5, 2, 1] — 排序后的排列,第 1 个元素已发生变化,因此答案为 “No”。
  3. [5, 2, 3, 4, 1] — 排序后的排列,第 3 个元素未发生变化,因此答案为 “Yes”。
  4. [5, 4, 3, 2, 1] — 排序后的排列,第 4 个元素未发生变化,因此答案为 “Yes”。
  5. [5, 1, 2, 3, 4] — 排序后的排列,第 3 个元素已发生变化,因此答案为 “No”。

输入解题思路,AI测评打分。不知道怎么写?

首页