#416 Div.2 B

题目

题意是说给你一个长为n的序列,有m次操作

序列的值从1~n,且每个数只出现一次

每次操作是将初始序列中的[l, r]区间的数从小到大排序,输出排序后位置p的值与原序列相比是否发生变化

直接上代码

 1 #include <cstdio>
 2 using namespace std;
 3
 4 const int maxn = 1e4 + 10;
 5 int n, q, a[maxn];
 6 int l, r, p;
 7
 8 int main(int argc, const char * argv[]) {
 9     scanf("%d%d", &n, &q);
10     for (int i = 1; i <= n; i++) {
11         scanf("%d", &a[i]);
12     }
13     for (int i = 0; i < q; i++) {
14         scanf("%d%d%d", &l, &r, &p);
15         int tmp = 0;
16         for (int j = l; j <= r; j++)  {
17             if (a[j] < a[p]) {
18                 tmp++;
19             }
20         }
21         if (tmp == (p - l)) {
22             printf("Yes\n");
23         } else {
24             printf("No\n");
25         }
26     }
27     return 0;
28 }

时间: 2024-08-04 14:08:06

#416 Div.2 B的相关文章

Codeforces Round #416 (Div. 2) C. Vladik and Memorable Trip

题目链接:Codeforces Round #416 (Div. 2) C. Vladik and Memorable Trip 题意: 给你n个数,现在让你选一些区间出来,对于每个区间中的每一种数,全部都要出现在这个区间. 每个区间的价值为该区间不同的数的异或值,现在问你这n个数最大的价值是多少. 题解: 比赛的时间直接就想到了做法,不过在选取合法区间的时候,细节上出了点小问题. 然后一直wa到怀疑人生.太菜了. 首先,先将合法的区间选取出来. 对于这些区间,按照左端点排序, 然后对于选出来的

(线段树+并查集) Codeforces Round #416 (Div. 2) E Vladik and Entertaining Flags

In his spare time Vladik estimates beauty of the flags. Every flag could be represented as the matrix n?×?m which consists of positive integers. Let's define the beauty of the flag as number of components in its matrix. We call component a set of cel

Codeforces Round #416 (Div. 2) A+B

A. Vladik and Courtesy 2 seconds 256 megabytes At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. After that Valera gave Vladik 2 his candies, so that no one thought that he was less gener

Codeforces Round #416 (Div. 2)

B 前几天听cwy说O(m*n)被卡常,比赛时犹豫了好久才写,然后就A了,STL的常数很牛逼 大概2种方法:根据下标位置判断这个数值是否改变(找k-th min): 根据值来确定其下标,判断下标是否改变(找这个数是第几小,常数小) C n^2 dp,当时加了一些mark,实际上由于0?≤?ai?≤?5000,完全可以每次dp memset一波 D 交互题. 比赛时因为有一个for把3写成4,导致内存溢出,调了1个多小时都没有发现,还是太粗心(不过即使如此好像rank还是挺前面的..) 真可惜呀,

【动态规划】 Codeforces Round #416 (Div. 2) C. Vladik and Memorable Trip

划分那个序列,没必要完全覆盖原序列.对于划分出来的每个序列,对于某个值v,要么全都在该序列,要么全都不在该序列. 一个序列的价值是所有不同的值的异或和.整个的价值是所有划分出来的序列的价值之和. 求整个的价值的最大值 f(i)表示最后一个划分序列的右端点为i时,1~i的答案. f(i)=max{max{f(j)}(1<=j<i)+xorsum(j+1,i)(j+1到i的区间合法)}(1<=i<=n) 需要在转移的时候,顺便处理f(i)的前缀max. 最终的答案就是所有f(i)的最大

【分类讨论】【spfa】【BFS】Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game

那个人第一步肯定要么能向下走,要么能向右走.于是一定可以判断出上下是否对调,或者左右是否对调. 然后他往这个方向再走一走就能发现一定可以再往旁边走,此时就可以判断出另一个方向是否对调. 都判断出来以后,跑个spfa或者bfs就行了. 细节较多--有一些边界情况需要处理.比如终点在第一行或者第一列的情况. #include<cstdio> #include<queue> #include<cstring> #include<algorithm> using n

Codeforces Round #416 (Div. 2) 811D Vladik and Favorite Game

题目链接: http://codeforces.com/problemset/problem/811/D 题目描述: D. Vladik and Favorite Game This is an interactive problem. Vladik has favorite game, in which he plays all his free time. Game field could be represented as n?×?m matrix which consists of ce

(dp) Codeforces Round #416 (Div. 2)

Vladik often travels by trains. He remembered some of his trips especially well and I would like to tell you about one of these trips: Vladik is at initial train station, and now n people (including Vladik) want to get on the train. They are already

DIV + CSS综合实例【传智PHP首页】

1.首页结构 2.准备工作 所有素材放到与当前网页同级的目录下: 网页背景色.背景图: 主页宽度:1000px: 创建CSS文件,将CSS文件引入到当前的HTML文件中. 3.实现 效果图: 源代码: HTML代码: 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&