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. thinkphp5.0 composer安装phpmailer

    1.安装:composer require phpmailer/phpmailer 2.引入:use PHPMailer\PHPMailer\PHPMailer: 3.调用:$mail = new P ...

  2. Effective C++: 05实现

    26:尽可能延后变量定义式的出现时间 1:只要你定义了一个变量而其类型带有一个构造函数或析构函数,那么当程序的控制流到达这个变量定义式时,你便得承受构造成本:当这个变量离开其作用域时,你便得承受析构成 ...

  3. MUI - 解决动态列表页图片懒加载再次加载不成功的bug

    首先描述一下功能 实现列表页动态加载 通过官方提供的"下拉刷新和上拉刷新"及"图片懒加载"示例实现. http://www.cnblogs.com/philly ...

  4. MySQL 获取当前月的天数

    select curdate();                       --获取当前日期 select DATE_ADD(curdate(),interval -day(curdate())+ ...

  5. HDU_1087-Super Jumping! Jumping! Jumping!

    Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...

  6. @bzoj - 4378@ [POI2015] Pustynia

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定一个长度为 n 的正整数序列 a,每个数都在 1 到 10^ ...

  7. vue filter使用方法

    Vue.js 允许你自定义过滤器,可被用于一些常见的文本格式化. 过滤器可以用在两个地方:双花括号插值和 v-bind 表达式 (后者从 2.1.0+ 开始支持). 过滤器应该被添加在 JavaScr ...

  8. iptables SNAT与伪装

    Source NAT(SNAT)的主要應用,是让同一內部網路上的多部主机,可共用同一条Internet实体连線.直接与Internet相连的闸道器,可使用SNAT(搭配连線追蹤)来来改写內部网络与In ...

  9. axios用headers传参,设置请求头token

    新建一个配置文件http.js // 导入axios import axios from 'axios'; // 全局配置默认路由 axios.defaults.baseURL = 'http://1 ...

  10. oracle使用表的别名(Alias)

    当在SQL语句中连接多个表时, 请使用表的别名并把别名前缀于每个Column上.这样一来,就可以减少解析的时间并减少那些由Column歧义引起的语法错误.   (Column歧义指的是由于SQL中不同 ...