codeforces#416 div2- Vladik and Complicated Book
来源:互联网 发布:网络词28是什么意思 编辑:程序博客网 时间:2024/05/16 15:11
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 = [p1, p2, ..., pn], where pi 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 px changed? After every sorting Vladik return permutation to initial state, so you can assume that each sorting is independent from each other.
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 p1, p2, ..., pn (1 ≤ pi ≤ n) — permutation P. Note that elements in permutation are distinct.
Each of the next m lines contains three space-separated integers li, ri, xi (1 ≤ li ≤ xi ≤ ri ≤ n) — left and right borders of sorted subsegment in i-th sorting and position that is interesting to Vladik.
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.
5 55 4 3 2 11 5 31 3 12 4 34 4 42 5 3
YesNoYesYesNo
6 51 4 3 2 5 62 4 31 6 24 5 41 3 32 6 3
YesNoYesNoYes
Explanation of first test case:
- [1, 2, 3, 4, 5] — permutation after sorting, 3-rd element hasn’t changed, so answer is "Yes".
- [3, 4, 5, 2, 1] — permutation after sorting, 1-st element has changed, so answer is "No".
- [5, 2, 3, 4, 1] — permutation after sorting, 3-rd element hasn’t changed, so answer is "Yes".
- [5, 4, 3, 2, 1] — permutation after sorting, 4-th element hasn’t changed, so answer is "Yes".
- [5, 1, 2, 3, 4] — permutation after sorting, 3-rd element has changed, so answer is "No".
#include<cstdio>#include<algorithm>#define maxn 10010using namespace std;int a[maxn];int n, m;int main() {scanf("%d %d", &n, &m);for (int i = 1;i <= n;i++) {scanf("%d", &a[i]);}int l, r, x;for (int j = 0;j < m;j++) {scanf("%d %d %d", &l, &r, &x);int t=0;for (int i = l;i <= r;i++) {if (a[i] < a[x]) t++;}if (t == x-l) printf("Yes\n");else printf("No\n");}return 0;}
- codeforces#416 div2- Vladik and Complicated Book
- Codeforces Round #416 (Div. 2) B. Vladik and Complicated Book
- Codeforces Round #416 (Div. 2) B. Vladik and Complicated Book
- Codeforces Round #416 (Div. 2) B. Vladik and Complicated Book
- Codeforces 811B Vladik and Complicated Book
- Codeforces 811 B Vladik and Complicated Book
- Vladik and Complicated Book
- B. Vladik and Complicated Book
- B. Vladik and Complicated Book
- codeforce Vladik and Complicated Book
- Codeforces 811B Vladik and Complicated Book[主席树]
- #416 Div.2 B. Vladik and Complicated Book
- CodeForce 811 B Vladik and Complicated Book
- codeforces——811B——Vladik and Complicated Book
- CodeForces 811B——Vladik and Complicated Book ——思维,模拟
- 主席树——Codeforces811B Vladik and Complicated Book
- codeforces #416 div2 811A-Vladik and Courtesy
- codeforce811b Vladik and Complicated Book(都是不好好想题惹的祸)
- JZOJ 5120 【2017.5.28提高组模拟】Summing Pieces
- 450. Delete Node in a BST
- SWJTU计算机组成实验C-实验七 指令存储器与取指令部件的设计
- 想写点啥东西
- 和webshell第一次亲密接触
- codeforces#416 div2- Vladik and Complicated Book
- 标识符、关键字和基本数据类型
- 17多继承
- 学习笔记三--ViewModel选项
- 有序广播和无序广播
- 学习笔记三--ViewModel选项
- 强制关闭 端口号
- [机器学习入门] 李宏毅机器学习笔记-3 (Gradient Descent ;梯度下降)
- 笔记UE4 的各个类型