原题连接: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. WEB框架实战总结

    Django 在新一代的 Web框架 中非常出色 使用Python开发Web,最简单,原始和直接的办法是使用CGI标准,可以用WSGI接口 一.WSGI接口实现web页面 运行WSGI服务 我们先编写 ...

  2. 【MM系列】SAP MM模块-科目分配的配置

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP MM模块-科目分配的配置   ...

  3. 关于Polyaxon的使用

    1.首先upload代码 polyaxon upload 注意,upload只能在新建notebook前进行,且每次只能upload一次,所以在结束每次项目测试(开发)前,都应该在Polyaxon上修 ...

  4. [转帖]Docker从入门到动手实践

    Docker从入门到动手实践 https://www.cnblogs.com/nsky/p/10853194.html dockerfile的图很好呢. 但是自己没有做实验 , 其实知识都挺好. do ...

  5. re库的使用

    re库的使用 精确匹配 如果直接给出字符,就是精确匹配.用\d可以匹配一个数字,\w可以匹配一个字母或数字 s1='00\d'#可以匹配'007',但是匹配不了'00A' s2='\d\d\d'#可以 ...

  6. Python基础编程闭包与装饰器

    闭包的定义 闭包是嵌套在函数中的函数. 闭包必须是内层函数对外层函数的变量(非全局变量)的引用. 闭包格式: def func(): lst=[] def inner(a): lst.append(a ...

  7. 利用CSS的translate属性或利用CSS实现图片居中的效果

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. Redis数据类型及基本命令

    一.基础命令 提示:Redis不区分命令大小写 1.获得符合规则的键名列表 keys pattern    //pattern支持glob风格通配符格式 2.判断一个键是否存在 exists key  ...

  9. node搭建个人博客promise警告解除

    警告 (node:8500) UnhandledPromiseRejectionWarning: undefined (node:8500) UnhandledPromiseRejectionWarn ...

  10. nroff - 用 groff 模拟 nroff 命令

    总览 (SYNOPSIS) nroff [ -h ] [ -i ] [ -mname ] [ -nnum ] [ -olist ] [ -rcn ] [ -Tname ] [ file... ] 描述 ...