Codeforces Round #416 (Div. 2) B. Vladik and Complicated Book
B. Vladik and Complicated Book
2 seconds
256 megabytes
standard input
standard output
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 5
5 4 3 2 1
1 5 3
1 3 1
2 4 3
4 4 4
2 5 3
Yes
No
Yes
Yes
No
6 5
1 4 3 2 5 6
2 4 3
1 6 2
4 5 4
1 3 3
2 6 3
Yes
No
Yes
No
Yes
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".
解题思路:
这道题简单的一笔,就是当时打的时候算了下复杂度懒得跟他多比比,直接暴力过了,结果被人出了个极限数据卡了时间复杂度,mmp!
被hack了,下面直接放代码,没啥讲的。以后不能瞎暴力了,要不迟早要翻水水
实现代码:
#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + ;
int n, m, a[N]; int main() {
cin>>n>>m;
for (int i = ; i <= n; i++) cin>>a[i];
while (m--) {
int l, r, x; cin>>l>>r>>x;
int cnt = ;
for (int i = l; i <= r; i++) {
if (a[i] < a[x]) cnt++;
}
if (x == l + cnt)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
}
Codeforces Round #416 (Div. 2) B. Vladik and Complicated Book的更多相关文章
- Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game
地址:http://codeforces.com/contest/811/problem/D 题目: D. Vladik and Favorite Game time limit per test 2 ...
- Codeforces Round #416 (Div. 2) C. Vladik and Memorable Trip
http://codeforces.com/contest/811/problem/C 题意: 给出一行序列,现在要选出一些区间来(不必全部选完),但是相同的数必须出现在同一个区间中,也就是说该数要么 ...
- Codeforces Round #416 (Div. 2) A. Vladik and Courtesy【思维/模拟】
A. Vladik and Courtesy time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- 【分类讨论】【spfa】【BFS】Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game
那个人第一步肯定要么能向下走,要么能向右走.于是一定可以判断出上下是否对调,或者左右是否对调. 然后他往这个方向再走一走就能发现一定可以再往旁边走,此时就可以判断出另一个方向是否对调. 都判断出来以后 ...
- 【动态规划】 Codeforces Round #416 (Div. 2) C. Vladik and Memorable Trip
划分那个序列,没必要完全覆盖原序列.对于划分出来的每个序列,对于某个值v,要么全都在该序列,要么全都不在该序列. 一个序列的价值是所有不同的值的异或和.整个的价值是所有划分出来的序列的价值之和. ...
- Codeforces Round #416 (Div. 2)(A,思维题,暴力,B,思维题,暴力)
A. Vladik and Courtesy time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...
- Codeforces Round#416 Div.2
A. Vladik and Courtesy 题面 At regular competition Vladik and Valera won a and b candies respectively. ...
- Codeforces Round #416 (Div. 2) A+B
A. Vladik and Courtesy 2 seconds 256 megabytes At regular competition Vladik and Valera won a and ...
- Codeforces Round #416 (Div. 2)A B C 水 暴力 dp
A. Vladik and Courtesy time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
随机推荐
- odoo之页面跳转
击备注时,会由备注id带出他的内容 customer.requirement这是备注内容表 def sale_requirements_change(self, cr, uid, ids, requi ...
- 基于Nginx+Keepalived的LB服务监控(邮件报警)
IDC两台机器上部署了Nginx+Keepalived主从模式的LB代理负载层,现在需要对LB进行每日巡检和服务监控,利用SendEmail邮件监控. 0)SendEmail部署 参考:http:// ...
- Linux下开源邮件系统Postfix+Extmail+Extman环境部署记录
一.基础知识梳理MUA (Mail User Agent) MUA 既是"邮件使用者代理人",因为除非你可以直接利用类似 telnet 之类的软件登入邮件主机来主动发出信件,否则您 ...
- webvirtmgr-重命名kvm虚拟机的名称
之前部署了Webvirtmgr平台管理kvm虚拟机,由于虚拟机在创建时名称是顺便起的,后续在虚拟机上部署了部分业务.为了便于管理,最好将虚拟机的名称重置下. 现在说下如何修改kvm中虚拟机的名称: 比 ...
- Redis主从复制原理总结
和Mysql主从复制的原因一样,Redis虽然读取写入的速度都特别快,但是也会产生读压力特别大的情况.为了分担读压力,Redis支持主从复制,Redis的主从结构可以采用一主多从或者级联结构,Redi ...
- Adobe Photoshop CC 2015使用及扩展工具
VAdobe Photoshop CC 2015: 简称"PS",是由Adobe Systems开发和发行的图像处理软件 扩展工具: Cuuterman:切图插件: 一个一个切图, ...
- @Scheduled 定时
此文章记录在spring boot项目中的使用 1,在项目的启动类中加注解@EnableScheduling,表示此项目可以进行定时 @SpringBootApplication @EnableSch ...
- Individual P1: Summary
经过5个小时成功把simple mode写差不多了..orz 也是蛮拼的. 开始毫无头绪,本能地开始从度娘搜索‘c# 单词统计’= =看了两段代码也算是见过c#的人了.差不多花了我1小时的时间. 然后 ...
- checkbox未选中不提交数据
如果checkbox为选中的话提交的数据为NULL function checkForm() { alert(($("#checkbox").get(0).checked)); i ...
- <<梦断代码>>阅读笔记一
没有想象中的枯燥,甚至有些有趣.这就是我对<梦断代码>这一本书的第一印象.而且,作为一本面向程序员的书籍,作者很有意义地从第0章开始,那我也从第0章开始说.这第一次读书笔记是针对0~2 章 ...