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

  • 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 alibecomes equal to old value of ari;
  • li ri — reverse the segment [li, ri].

There are m important indices in the array b1b2, ..., 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 nq and m (1 ≤ n, q ≤ 2·105, 1 ≤ m ≤ 100).

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

Then q lines follow. i-th of them contains three integer numbers tiliri, 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 b1b2, ..., 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.

Example

Input
6 3 5
1 2 3 4 5 6
2 1 3
2 3 6
1 1 6
2 2 1 5 3
Output
3 3 1 5 2 

题意:
对一个数组,有两种操作,1:翻转 2 左移
问所有操作完成后,位置p的数是多大.
思路:
对于当前操作,之后的操作与之无关,所以直接暴力反推,p由哪个位置转移来即可
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<ctime> #define fuck(x) cerr<<#x<<" = "<<x<<endl;
#define debug(a, x) cerr<<#a<<"["<<x<<"] = "<<a[x]<<endl;
#define ls (t<<1)
#define rs ((t<<1)|1)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int loveisblue = ;
const int maxn = ;
const int maxm = ;
const int inf = 0x3f3f3f3f;
const ll Inf = ;
const int mod = ;
const double eps = 1e-;
const double pi = acos(-); int num[maxn];
struct node{
int l,r,type;
}a[maxn];
int main() {
// ios::sync_with_stdio(false);
// freopen("in.txt", "r", stdin); int n,q,m;
scanf("%d%d%d",&n,&q,&m);
for(int i=;i<=n;i++){
scanf("%d",&num[i]);
}
for(int i=;i<=q;i++){
scanf("%d%d%d",&a[i].type,&a[i].l,&a[i].r);
} while (m--){
int x;
scanf("%d",&x);
for(int i=q;i>=;i--){
if(a[i].l>x||a[i].r<x){ continue;}
if(a[i].type==){
if(a[i].l==x){
x=a[i].r;
}else {
x--;
}
}else{
int y = a[i].r - x;
x = a[i].l+y;
}
}
printf("%d ",num[x]);
} return ;
}

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

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

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

  2. [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: ...

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

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

  4. Light oj 1100 - Again Array Queries (鸽巢原理+暴力)

    题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1100 给你n个数,数的范围是1~1000,给你q个询问,每个询问问你l到r之间 ...

  5. Codeforces 797E - Array Queries

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

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

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

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

                                                                              1100 - Again Array Queries ...

  8. lightoj Again Array Queries

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

  9. Military Problem CodeForces 1006E (dfs序)

    J - Military Problem CodeForces - 1006E 就是一道dfs序的问题 给定一个树, 然后有q次询问. 每次给出u,k, 求以u为根的子树经过深搜的第k个儿子,如果一个 ...

随机推荐

  1. [ 浙江大学 数据库系统原理 ] [ MiniSQL ]课程设计

    工作流程图如下.代码详见https://github.com/gstggsstt/minisql. 注:课程设计时间紧迫,编码基本没有性能考虑,仅限于实现功能,索引未使用B+tree.

  2. Ubuntu官方源

    由于国内使用官方源导致下载速度慢等各方面原因,很多人将官方源替换成阿里源等,但是某些应用安装会报错.现将官方源分享如下: 备份当前源: 执行命令:# sudo cp /etc/apt/sources. ...

  3. 【JZOJ4832】【NOIP2016提高A组集训第3场10.31】高维宇宙

    题目描述 数据范围 解法 由于大于4的素数只有可能由奇数和偶数的和得出. 所以根据数的奇偶性可以分出两类数奇数和偶数. 奇数之间不会相互匹配,偶数之间也不会相互匹配. 那么原问题转化为二分图最大匹配. ...

  4. 小爬爬2:fiddler安装和了解fiddler

    1.解压安装就可以了 fiddler优点:抓取移动和PC机器的请求 2.首先进行证书的配置 如果不配置只能抓取http的请求,https不能抓取. 先选择,第一个"清空所有内容" ...

  5. Laravel请求和输入

    该篇文章主要介绍Laravel获取用户请求和输入信息的方法.获取基本输入信息: //获取输入数据,不用担心所使用的HTTP方法 $id = Input::get('id'); //可以指定默认值 $i ...

  6. 2019-11-1-asp-dotnet-core-简单开发P2P中央服务器

    title author date CreateTime categories asp dotnet core 简单开发P2P中央服务器 lindexi 2019-11-01 19:40:33 +08 ...

  7. 巨蟒python全栈开发-第11阶段 ansible3_2入门八个模块

    大纲: 1.file模块 2.fetch模块 3.yum&&pip模块 4.service模块 5.cron模块 6.user模块 7.group模块

  8. Android学习:导入工程时报错The import android cannot be resolved

    今天在导入别人的工程时,出现了一个这个问题The import android cannot be resolved 就是找不到import android.support.v7.app.Action ...

  9. 待性能改善的一个SQL

    select t.*, t.rowid from tb_tk_datasakusei_ctrl t; alter table ATOMBB.TB_TK_JISSEKI_INFO_DETAIL add ...

  10. 一条数据的漫游 -- X-Engine SIGMOD Paper Introduction

    大多数人追寻永恒的家园(归宿),少数人追寻永恒的航向. ----瓦尔特.本雅明 背景 X-Engine是阿里数据库产品事业部自研的OLTP数据库存储引擎,作为自研数据库POLARDB X的存储引擎,已 ...