B. Vladik and Complicated Book
来源:互联网 发布:mysql如何安装 编辑:程序博客网 时间:2024/06/06 03: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 permutationP = [p1, p2, ..., pn], where pi denotes the number of page that should be readi-th in turn.
Sometimes Vladik’s mom sorted some subsegment of permutation P from position l to positionr inclusive, because she loves the order. For every of such sorting Vladik knows numberx — 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, haspx 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 integersp1, p2, ..., pn (1 ≤ pi ≤ n) — permutationP. Note that elements in permutation are distinct.
Each of the next m lines contains three space-separated integersli,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".
//2.#if 0#include<bits/stdc++.h>using namespace std;int main(){int n,t,a[10000];while(cin>>n>>t){for(int i=1; i<=n; i++){cin>>a[i];}while(t--){int l,r,p;cin>>l>>r>>p;if(p<l&&p>r){cout<<"Yes"<<endl;}else{int c[10000]={0},d[10000]={0},num=0;for(int i=l; i<=r; i++) {if(a[i]<a[p])num++; }if(a[p]==a[l+num]) {cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}//sort(c,c+(r-l+1));/*for(int i=0; i<l-1; i++){d[i]=a[i];}for(int i=l-1; i<=r-1; i++){d[i]=c[i-l+1];}for(int i=r; i<n; i++){d[i]=a[i];}/*for(int i=0; i<n; i++){cout<<d[i];}cout<<endl;*/}}}}#endif
- B. Vladik and Complicated Book
- B. Vladik and Complicated Book
- CodeForce 811 B Vladik and Complicated Book
- Codeforces 811B Vladik and Complicated Book
- Codeforces 811 B Vladik and Complicated Book
- Vladik and Complicated Book
- codeforce Vladik and Complicated Book
- Codeforces Round #416 (Div. 2) B. Vladik and Complicated Book
- #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#416 div2- Vladik and Complicated Book
- codeforces——811B——Vladik and Complicated Book
- CodeForces 811B——Vladik and Complicated Book ——思维,模拟
- 主席树——Codeforces811B Vladik and Complicated Book
- codeforce811b Vladik and Complicated Book(都是不好好想题惹的祸)
- Mister B and Book Reading
- Docker 安装使用(centos)
- Linux 中启动Eclipse 出现异常 Exit code =13解决方法
- 设计模式:单例模式
- 模块化编程
- FZU 2282Problem 2282 Wand(错排+快速幂+费马小定理)
- B. Vladik and Complicated Book
- POJ-2773 欧几里得 + 二分 + 容斥
- concurrent(四)
- TensorFlow 之基于Inception V3的多标签分类 retrain
- win10系统怎么通过ssh连接到本机virtual box中安装的centos7系统
- 机器学习面试问题总结
- 2017年08月08日
- 嵌入式每日学习心得2017.08.08
- C++实现Sqlite3增删改查