Description

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

  • 1 li ri — perform a cyclic shift of the segment [li, ri] to the right. That is, for every x such that li ≤ x < ri new value of ax + 1 becomes equal to old value of ax, and new value of ali becomes equal to old value of ari;
  • 2 li ri — reverse the segment [li, ri].

There are m important indices in the array b1, b2, ..., bm. For each i such that 1 ≤ i ≤ m you have to output the number that will have index bi in the array after all queries are performed.

Input

The first line contains three integer numbers n, q and m (1 ≤ n, q ≤ 2·105, 1 ≤ m ≤ 100).

The second line contains n integer numbers a1, a2, ..., an (1 ≤ ai ≤ 109).

Then q lines follow. i-th of them contains three integer numbers ti, li, ri, where ti is the type of i-th query, and [li, ri] is the segment where this query is performed (1 ≤ ti ≤ 2, 1 ≤ li ≤ ri ≤ n).

The last line contains m integer numbers b1, b2, ..., bm (1 ≤ bi ≤ n) — important indices of the array.

Output

Print m numbers, i-th of which is equal to the number at index bi after all queries are done.

Sample Input

6 3 5
1 2 3 4 5 6
2 1 3
2 3 6
1 1 6
2 2 1 5 3

Sample Output

3 3 1 5 2 

题解

官方给出的标签是数据结构...确实可以打个链表,但你发现$m<=100$,我们甚至暴力模拟都不会超时。

我们离线所有的操作,我们每读入一个询问,倒序操作模拟一遍就好了。

 //It is made by Awson on 2017.9.30
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Max(a, b) ((a) > (b) ? (a) : (b))
using namespace std;
const int N = 2e5;
void read(int &x) {
char ch; bool flag = ;
for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == '-')) || ); ch = getchar());
for (x = ; isdigit(ch); x = (x<<)+(x<<)+ch-, ch = getchar());
x *= -*flag;
} struct Query {
int id, l, r;
}query[N+];
int n, q, m, p;
int a[N+]; void work() {
read(n), read(q), read(m);
for (int i = ; i <= n; i++) read(a[i]);
for (int i = ; i <= q; i++)
read(query[i].id), read(query[i].l), read(query[i].r);
while (m--) {
scanf("%d", &p);
for (int i = q; i >= ; i--) {
if (query[i].l <= p && query[i].r >= p) {
if (query[i].id == ) {
if (query[i].l == p) p = query[i].r;
else p--;
}
else {
p = query[i].r-(p-query[i].l);
}
}
}
printf("%d ", a[p]);
}
printf("\n");
}
int main() {
work();
return ;
}

[Codeforces 863D]Yet Another Array Queries Problem的更多相关文章

  1. 863D - Yet Another Array Queries Problem(思维)

    原题连接:http://codeforces.com/problemset/problem/863/D 题意:对a数列有两种操作: 1 l r ,[l, r] 区间的数字滚动,即a[i+1]=a[i] ...

  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. Educational Codeforces Round 19 E. Array Queries(暴力)(DP)

    传送门 题意 给出n个数,q个询问,每个询问有两个数p,k,询问p+k+a[p]操作几次后超过n 分析 分块处理,在k<sqrt(n)时,用dp,大于sqrt(n)用暴力 trick 代码 #i ...

  4. Codeforces 797E - Array Queries

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

  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. lightoj Again Array Queries

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

  8. Codeforces 442C Artem and Array(stack+贪婪)

    题目连接:Codeforces 442C Artem and Array 题目大意:给出一个数组,每次删除一个数.删除一个数的得分为两边数的最小值,假设左右有一边不存在则算作0分. 问最大得分是多少. ...

  9. Codeforces Round #504 D. Array Restoration

    Codeforces Round #504 D. Array Restoration 题目描述:有一个长度为\(n\)的序列\(a\),有\(q\)次操作,第\(i\)次选择一个区间,将区间里的数全部 ...

随机推荐

  1. fcode-页面九宫格自动锁屏jquery插件

    fcode.js 自动锁屏插件 fcode.js是什么? fcode.js是一款web页面九宫格自动锁屏js插件,依赖于jquery, 会在设置的范围里,判断用户有无操作,然后执行锁屏的功能. 就一个 ...

  2. 剑指offer-删除链表中重复的节点

    题目描述   在一个排序的链表中,存在重复的结点,请删除该链表中重复的结点,重复的结点不保留,返回链表头指针. 例如,链表1->2->3->3->4->4->5 处 ...

  3. AngularJS1.X学习笔记13-路由

    ThinkPHP框架有路由的概念,看起来路由更多的是后端的事情,Angular怎么也会跑出个路由呢?事实上,Angular是着眼于单页应用的,他的一个应用一般来说是一个页面,你所看到的页面内容的改变, ...

  4. linux ubunt 安装软件的前期准备——更新源的更换

    如果是高手,请翻到页面最下方,更换更新源的总结,直接操作即可 可能会优点啰嗦,但是认真看,一定能解决问题~~希望对大家有帮助~ 最近在熟悉linux环境,自己安装了一个ubuntu虚拟机. 很多朋友问 ...

  5. HTNL表单详解

    HTML表单 表单的结构 表单的标签:<form> </form> 常用属性 Name , method(get,post), action(服务器的接收的页面如:reg.ph ...

  6. linux系统下的SVN安装

    1.直接安装 # sudo apt-get install subversion 2. 创建版本库 # sudo mkdir /home/svn # sudo svnadmin create /hom ...

  7. POJ-1751 Highways---确定部分边的MST

    题目链接: https://vjudge.net/problem/POJ-1751 题目大意: 有一个N个城市M条路的无向图,给你N个城市的坐标,然后现在该无向图已经有M条边了,问你还需要添加总长为多 ...

  8. python如何转换word格式、读取word内容、转成html

    # python如何转换word格式.读取word内容.转成html? import docx from win32com import client as wc # 首先将doc转换成docx wo ...

  9. Azure AI 服务之文本翻译

    当下人工智能可谓是风头正劲,几乎所有的大厂都有相关的技术栈.微软在 AI 领域自然也是投入了重注,并且以 Azure 认知服务的方式投入了市场: 也就是说作为开发者我们不需要学习太多 AI 的理论知识 ...

  10. cuda小白基础教程

    一直很想做cuda-GPU编程,很早就将CUDA9.0安装好了,后面就没怎么管它,忙别的去了.敲黑板,划重点,我科研还是很努力的,可是很多人看不见罢了.之前一直在使用粒子方法进行流体模拟,计算时间极其 ...