CodeForce 811 B Vladik and Complicated Book
来源:互联网 发布:淘宝运营自我介绍 编辑:程序博客网 时间:2024/06/05 22:35
题目链接:点击打开链接
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".
题意是给你一组数和几次操作,下面给出m组数据,包括一个区间和一个位置。需要对区间进行排序,问排序后是否还是当前的数字。
排序是肯定超时的,要判断修改后这个位置的数的前面有多少数字,是否等于以前个数的和。水题,但我以为是交换,没看懂是排序。
代码实现:
#include<iostream>#include<algorithm>#include<cstring>using namespace std;int main(){int b[10005],x,y,z,m,n,i,j;while(cin>>m>>n){for(i=0;i<m;i++)cin>>b[i];for(i=0;i<n;i++) {cin>>x>>y>>z; //输入区间和数字 int count=0; for(j=x-1;j<y;j++) //区间遍历 {if(b[j]<b[z-1]) //记录比第z个数字小的那一个 count++;}if(count==z-x) //如果,比第z个数字小的个数等于区间内z左边的数字 cout<<"Yes"<<endl;elsecout<<"No"<<endl; }}return 0;}
- CodeForce 811 B Vladik and Complicated Book
- codeforce Vladik and Complicated Book
- Codeforces 811B Vladik and Complicated Book
- Codeforces 811 B Vladik and Complicated Book
- B. Vladik and Complicated Book
- B. Vladik and Complicated Book
- Codeforces 811B Vladik and Complicated Book[主席树]
- 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 811B——Vladik and Complicated Book ——思维,模拟
- codeforces#416 div2- Vladik and Complicated Book
- 主席树——Codeforces811B Vladik and Complicated Book
- codeforce811b Vladik and Complicated Book(都是不好好想题惹的祸)
- codeforce.Vladik and flights
- A Discriminative Feature Learning Approach for Deep Face Recognition
- OpenCV笔记大集锦
- (148)光束
- Magento 2中文手册教程
- npm hotnode 踩坑
- CodeForce 811 B Vladik and Complicated Book
- codeforces 797C
- 欢迎使用CSDN-markdown编辑器
- redis
- LeetCode:Remove Duplicates from Sorted List II
- maven-filters 根据配置,自动编译不同环境下的包
- java并发编程学习(1)
- 程序员面试金典——堆箱子____
- 【实训】第四周总结上