CodeForce-811B Vladik and Complicated Book(水题)
http://codeforces.com/problemset/problem/811/B
题意:
给定一个长度为 N 不重复的数字序列,然后对其进行 M 次询问。
每次询问含L,R,X三个值,问如果数字序列中的 L ~ R 位置范围内进行从小到大的排序后,原本位置为 X 的数字是否变了。
由于 N 和 M 的范围都很小(10000),甚至不用模拟排序,对于每次询问直接 L ~ R 过一遍看有多少个元素小于 X 位置的那个,如果这个计数正好等于 X-L,那么位置为 X 的那个元素自然不会变。
贴上水码:
#include<iostream>
using namespace std;
int p[10050];
int main()
{
int n, m;
int l, r, x;
cin >> n >> m;
for (int i = 0; i < n; i++)
{
cin >> p[i];
}
for (int i = 0; i < m; i++)
{
cin >> l >> r >> x;
int cnt = 0;
for (int j = l-1; j <= r-1; j++)
{
if (p[j] < p[x-1])
cnt++;
}
if (cnt == x - l)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}
CodeForce-811B Vladik and Complicated Book(水题)的更多相关文章
- codeforces 664A A. Complicated GCD(水题)
题目链接: A. Complicated GCD time limit per test 1 second memory limit per test 256 megabytes input stan ...
- codeforce 839A Arya and Bran(水题)
Bran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going ...
- CodeForce 614B Gena's Code(水题)
这道题提醒我两点: 1.break时一定要检查清楚 2.字符串直接赋值一定要注意结束符,最好能用strcpy 以上是debug的惨痛教训 #include <iostream> #incl ...
- CodeForces 811B Vladik and Complicated Book
离线,树状数组. 数据范围好像有点小,直接暴力可以过的. 我直接上了$n,Q≤100000$的做法:只需要判断区间上比$x$小的数字有几个即可,可以对询问进行离线操作,从左到右一个一个数字插入到树状数 ...
- codeforce A. 2Char(水题,暴力)
今晚发了个蛇精病,然后CF了,第一题这好难啊,然而水题一个,暴力飘过. 链接http://codeforces.com/contest/593/problem/A: 题意比较难懂吗?傻逼百度都翻译不对 ...
- Codeforces Round #334 (Div. 2) A. Uncowed Forces 水题
A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/pro ...
- Codeforces 811 B. Vladik and Complicated Book
B. Vladik and Complicated Book time limit per test 2 seconds memory limit per test 256 megabytes i ...
- Brain Network (easy)(并查集水题)
G - Brain Network (easy) Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
随机推荐
- Spring学习笔记--面向切面编程(AOP)
什么是AOP AOP(Aspect Oriented Programming),意为面向切面编程,通过预编译方式和运行期间动态代理实现程序功能的统一维护的一种技术.AOP是OOP的延续,是软件开发中的 ...
- Semi-automation Script Based on Sleep
The following script auto login to server 49, send 2 commands and exit from the server. Create a aut ...
- Build a ZenTao Server on Linux
Download xampp for linux on Apache Friends, file name: xampp-linux-1.8.3-2-installer.run; Intallatio ...
- Shell-13-常用文件目录
linux系统目录结构 环境变量文件 系统级 系统级变量文件对所有用户生效 #系统范围内的环境变量和启动文件. #不建议把要做的事情写在这里面,最好创建一个自定义的,放在/etc/profile.d ...
- Java HashMap【笔记】
Java HashMap[笔记] HashMap HashMap 基本结构 HashMap 底层的数据结构主要是数组 + 链表 + 红黑树 其中当链表的长度大于等于 8 时,链表会转化成红黑树,当红黑 ...
- 关于下载远程文件为未知文件.txt的解决方法
本地下载文件后缀正常,服务器下载文件后缀都为.txt的解决方法: 后缀为 未知文件.txt 的原因为前端无权限获取Content-Disposition中的文件名 response.setHeader ...
- 题解 marshland
传送门 是个最大费用可行流 这题的建边很毒瘤 首先有危险度的点肯定要拆点 关键在于其它点怎么办 如果拆了不好保证每个点只经过一次 不拆连网络流都跑不了 但仔细观察题面,不能不难(???)发现一个L中那 ...
- centos7-同步时间
yum install -y ntp ntpdate ntpdate -u cn.pool.ntp.org # 阿里云ntp ntpdate ntp1.aliyun.com 但这样的同步,只是强制性的 ...
- Fancytree实例
一.实例 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> ...
- (1)hadoop之----linux配置jdk环境
首先Linux中应有jdk包 运用flashFXP上传文件,xshell连接linux系统 我一般将文件放在个人目录下softwear目录 ,软件装在个人目录下app目录 cd software ...