863D - Yet Another Array Queries Problem(思维)
原题连接: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(思维)的更多相关文章
- [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: ...
- 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 ...
- Codeforces 797E - Array Queries
E. Array Queries 题目链接:http://codeforces.com/problemset/problem/797/E time limit per test 2 seconds m ...
- lightoj Again Array Queries
1100 - Again Array Queries PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limit: 32 ...
- codeforces 797 E. Array Queries【dp,暴力】
题目链接:codeforces 797 E. Array Queries 题意:给你一个长度为n的数组a,和q个询问,每次询问为(p,k),相应的把p转换为p+a[p]+k,直到p > n为 ...
- AC日记——Array Queries codeforces 797e
797E - Array Queries 思路: 分段处理: 当k小于根号n时记忆化搜索: 否则暴力: 来,上代码: #include <cmath> #include <cstdi ...
- Light OJ-1082 - Array Queries,线段树区间查询最大值,哈哈,水过~~
...
- Light oj-1100 - Again Array Queries,又是这个题,上次那个题用的线段树,这题差点就陷坑里了,简单的抽屉原理加暴力就可以了,真是坑~~
1100 - Again Array Queries ...
- 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 ...
随机推荐
- Django聚合数据
背景: 有些时候,光靠数据库中已有字段的数据,还不足以满足一些特殊场景的需求,例如显示一个作者的所有书籍数量. 这时候就需要在已有数据基础上,聚合出这些没有的数据. 为查询集生产聚合: Django ...
- 【Linux开发】如何在./configure的时候将编译参数传入,改变默认的编译器gcc成arm-linux-gcc
如何在configure时,将编译参数传入,改变默认的编译器gcc成arm-linux-gcc [问题] 想要用交叉编译工具arm-linux-gcc去编译lrzsz, 但是在./configure的 ...
- kafka使用问题解决
java.lang.UnsupportedClassVersionError:org/apach/kafka/comon/utils/Utils:Unsupport major.minor versi ...
- 安装配置php及fastadmin
FastAdmin教程之准备运行环境 一.Node.js http://nodejs.cn/download/ https://npm.taobao.org/mirrors/node/v8.4.0 ...
- 逆序单词 HIhoCoder 1366 字典树
逆序单词 HIhoCoder 1366 字典序 题意 在英文中有很多逆序的单词,比如dog和god,evil和live等等. 现在给出一份包含N个单词的单词表,其中每个单词只出现一次,请你找出其中有多 ...
- [Codeforces 1214D]Treasure Island(dfs)
[Codeforces 1214D]Treasure Island(dfs) 题面 给出一个n*m的字符矩阵,'.'表示能通过,'#'表示不能通过.每步可以往下或往右走.问至少把多少个'.'变成'#' ...
- Scrapy 教程(一)-安装与入门
安装 具体请自行百度 依赖库 网上说pip安装会内分泌失调,我试了下还行吧,不过也遇到几个问题 解决方法 pip install -I cryptography 解决方法 pip install -U ...
- mysqldump: [Warning] Using a password on the command line interface can be insecure.
MySQL 5.6 警告信息 command line interface can be insecure 修复 在命令行输入密码,就会提示这些安全警告信息. Warning: Using a pas ...
- Hive配置日志
1. 重命名hive/conf文件夹下的hive-log4j 2. 修改hive.log.dir参数,如果不修改默认hive.log位于/tmp/{user}下面,一般来说使用在hive目录下自己创建 ...
- python利用(threading,ThreadPoolExecutor.map,ThreadPoolExecutor.submit) 三种多线程方式处理 list数据
需求:在从银行数据库中取出 几十万数据时,需要对 每行数据进行相关操作,通过pandas的dataframe发现数据处理过慢,于是 对数据进行 分段后 通过 线程进行处理: 如下给出 测试版代码,通过 ...