Codeforces 863DYet Another Array Queries Problem
来源:互联网 发布:美工在线培训 编辑:程序博客网 时间:2024/05/29 11:35
题意 :
一个序列支持两种操作
1. 将 l 到 r 向右移动一个单位
2. 将l 到 r 翻转
题解 :
首先注意到这个题目是一种离线的查询方式,另外又发现这个题最后的询问只有100个,这样的话我们不难想到这个题目应该有 O( 100 * 2e5 ) 的算法。考虑到每一次的操作只会影响在这个操作后面的操作,但是不会影响前面的操作,所以我们只需要逆序的将所有的操作模拟一遍就可以了。
#include <iostream>#include <algorithm>#include <cstring>#include <cstdio>using namespace std;const int maxn = 2e5 + 10;struct node { int type,l,r;}Q[maxn];int n,q,m;int a[maxn] = {0};int b[105] = {0};int solve (int x) { for (int i = 1;i <= q; ++ i) { if (Q[i].l <= x && Q[i].r >= x) { if (Q[i].type == 1) { x --; if (x == Q[i].l - 1) x = Q[i].r; } else { x = Q[i].l + Q[i].r - x; } } } return a[x];}int main () { ios_base :: sync_with_stdio(false); cin >> n >> q >> m; for (int i = 1;i <= n; ++ i) { cin >> a[i]; } for (int i = q;i >= 1; -- i) { cin >> Q[i].type >> Q[i].l >> Q[i].r; } for (int i = 1;i <= m; ++ i) { int x; cin >> x; cout << solve (x) << ' '; } return 0;}
阅读全文
0 0
- Codeforces 863DYet Another Array Queries Problem
- D.Yet Another Array queries Problem
- CF 863D. Yet Another Array Queries Problem 逆向思维,递归
- codeforces 797 E Array Queries
- codeforces 797E Array Queries
- Codeforces 797E Array Queries
- Codeforces 797E Array Queries
- codeforces 797E Array Queries
- Another Problem on Strings CodeForces
- CodeForces 266E More Queries to Array...
- Codeforces 797E Array Queries 分块思想
- Educational Codeforces Round 19 E. Array Queries
- Codeforces-797E-Array Queries(dp)
- Educational Codeforces Round 19-E. Array Queries
- CodeForces 165C - Another Problem on Strings
- codeforces 之 Another Problem on Strings
- CodeForces 165C - Another Problem on Strings
- codeforces-165C-Another Problem on Strings
- Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0
- mac OSX10.12 sierra 安装python-ldap报missing sasl.h错误
- 单例模式之懒汉的并发问题
- Java 数据结构
- 87.乱串追源
- Codeforces 863DYet Another Array Queries Problem
- 为什么V8引擎这么快?
- bzoj 2212(线段树合并)
- 干货 | 深度学习之DNN的多种正则化方式
- gradle镜像文件地址
- java闪屏类
- 面向对象的“形”与“本”
- vue2.0实现引用qrcode.js实现获取改变二维码的样式(2)
- Spring Boot AOP之对请求的参数入参与返回结果进行拦截处理