原题连接:http://codeforces.com/problemset/problem/863/D

题意:对a数列有两种操作:

1 l r ,[l, r] 区间的数字滚动,即a[i+1]=a[i], a[l]=a[r]

2 l r ,[l, r] 区间的数字位置反转。

若干个操作之后输出a[b[i]].

思路:

由于是在操作结束后输出,且b[i]的个数不多(<=100),所以可以通过反推求出答案。

AC代码:

 #include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long LL;
const int MAXN = 2e5+;
struct Query {
int type;
int l,r;
}Q[MAXN];
int a[MAXN];
int n, q, m;
void print(int b)
{
for (int i = ;i <= q;i++) {
if (b >= Q[i].l&&b <= Q[i].r) {
if (Q[i].type == ) {
b--;
if (b < Q[i].l)
b = Q[i].r;
}
else
b = Q[i].r - (b - Q[i].l);
}
}
printf("%d", a[b]);
return;
}
int main() { scanf("%d %d %d", &n, &q, &m);
for (int i = ;i <= n;i++) {
scanf("%d", &a[i]);
}
for (int i = q;i >= ;i--) {
scanf("%d %d %d", &Q[i].type, &Q[i].l, &Q[i].r);
}
int b;
for (int i = ;i < m;i++) {
scanf("%d", &b);
if (i != ) printf(" ");
print(b);
}
printf("\n");
return ;
}

863D - Yet Another Array Queries Problem(思维)的更多相关文章

  1. [Codeforces 863D]Yet Another Array Queries Problem

    Description You are given an array a of size n, and q queries to it. There are queries of two types: ...

  2. Yet Another Array Queries Problem CodeForces - 863D (暴力/思维)

    You are given an array a of size n, and q queries to it. There are queries of two types: 1 li ri — p ...

  3. Codeforces 797E - Array Queries

    E. Array Queries 题目链接:http://codeforces.com/problemset/problem/797/E time limit per test 2 seconds m ...

  4. lightoj Again Array Queries

    1100 - Again Array Queries   PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limit: 32 ...

  5. codeforces 797 E. Array Queries【dp,暴力】

    题目链接:codeforces 797 E. Array Queries   题意:给你一个长度为n的数组a,和q个询问,每次询问为(p,k),相应的把p转换为p+a[p]+k,直到p > n为 ...

  6. AC日记——Array Queries codeforces 797e

    797E - Array Queries 思路: 分段处理: 当k小于根号n时记忆化搜索: 否则暴力: 来,上代码: #include <cmath> #include <cstdi ...

  7. Light OJ-1082 - Array Queries,线段树区间查询最大值,哈哈,水过~~

                                                                                                        ...

  8. Light oj-1100 - Again Array Queries,又是这个题,上次那个题用的线段树,这题差点就陷坑里了,简单的抽屉原理加暴力就可以了,真是坑~~

                                                                              1100 - Again Array Queries ...

  9. CF797E. Array Queries

    a is an array of n positive integers, all of which are not greater than n. You have to process q que ...

随机推荐

  1. CSS3——注释 id 和 class 选择器 css创建(外部、内部、内联样式表)

    注释 /*         注释内容          */ id 和 class 选择器 id   ID属性不要以数字开头,数字开头的ID在 Mozilla/Firefox 浏览器中不起作用 < ...

  2. Java ——运算符

    本节重点思维导图 递增递减 前缀自增自减法(++a,--a): 先进行自增.减运算,再进行表达式运算 后缀自增自减法(a++,a--): 先进行表达式运算,再进行自增.减运算 例[1]: int a ...

  3. python gevent(协程模块)

    Python通过yield提供了对协程的基本支持,但是不完全.而第三方的gevent为Python提供了比较完善的协程支持. gevent是第三方库,通过greenlet实现协程,其基本思想是: 当一 ...

  4. 无法在发送 HTTP 标头之后进行重定向

    public ActionResult Index2() { Response.Buffer = true; Response.Clear(); return Redirect("/Wech ...

  5. ---Mock---基本使用

    一.mock解决的问题 开发时,后端还没完成数据输出,前端只好写静态模拟数据.数据太长了,将数据写在js文件里,完成后挨个改url.某些逻辑复杂的代码,加入或去除模拟数据时得小心翼翼.想要尽可能还原真 ...

  6. myBatis 基于javaBean配置

    MyBatis的持久化解决方案是将用户从原始的JDBC访问中解放出来,用户只需要定义需要操作的SQL语句, 无须关注底层的JDBC操作,就可以以面向对象的方式来进行持久化层操作.底层数据库连接的获取, ...

  7. java8 stream取出 最大值/最小值

    注:转载请注明出处!!! 这里直接用取出多个对象中某个值 最大/最小 来进行举例 直接看代码 /** * 时间测试类 */ class TimeTest { private Date time; pu ...

  8. [19/05/27-星期一] JavaScript_ 条件语句(if语句)和循环语句(while 、for、do-while)

    一.条件语句 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <ti ...

  9. CentOS卸载lamp环境的步骤

    学习PHP的时候需要在CentOS系统下安装lamp环境,安装容易卸载就没那么简单了,因为lamp由Apache.MySQL.PHP三个部分构成,需要逐个卸载,小编就给大家介绍下CentOS卸载lam ...

  10. K8S工作原理

    kubernetes(k8s)是docker容器用来编排和管理的工具 我们通过kubectl向k8s Master发出指令.kubernetes Master主要是提供API Server.Sched ...