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 ...
随机推荐
- 【ABAP系列】SAP Web Dynpro 技术简介
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP Web Dynpro 技 ...
- 应用安全 - 无文件式攻击 - 工具型攻击 - PowerShell - 汇总
PowerShell 使用 | 命令 win+r ->powershell #启动Powershell窗口 get-host #查看版本 Get-Host | Select-Object Ver ...
- itchat监听微信撤回消息
import itchat from itchat.content import * import re msg_infomation = {} # 监听发送消息 @itchat.msg_regist ...
- Spring Security Session Time Out
最近在用Spring Security做登录管理,登陆成功后,页面长时间无操作,超过session的有效期后,再次点击页面操作,页面无反应,需重新登录后才可正常使用系统. 为了优化用户体验,使得在se ...
- 不容错过的 MySQL史上最全
点击下方链接 http://c.biancheng.net/view/2361.html
- 【嵌入式 Linux文件系统】如何使用NFS文件系统
(1)内核配置 取消选项 General setup-->Initial RAM filesystem and RAM disk (initramfs/initrd) support 进入Fil ...
- docker下部署kafka集群(多个broker+多个zookeeper)
网上关于kafka集群的搭建,基本是单个broker和单个zookeeper,测试研究的意义不大.于是折腾了下,终于把正宗的Kafka集群搭建出来了,在折腾中遇到了很多坑,后续有时间再专门整理份搭建问 ...
- python中输入三个整数x,y,z,请把这三个数由小到大输出。
输入三个整数x,y,z,请把这三个数由小到大排序,再把数组由大到小排序,再输出最大值和最小值! #定义一个空数组 numbers = [] #循环遍历,下面的4是控制循环次数 for i in ran ...
- HNUSTOJ-1257 You are my brother
1257: You are my brother 时间限制: 1 Sec 内存限制: 128 MB提交: 39 解决: 15[提交][状态][讨论版] 题目描述 Little A gets to ...
- 01-Django-urls
# Django系统- 环境 - python3.6 - django1.18- 参考资料 - [django中文教程](http://python.usyiyi.cn/)# 环境搭建- anacon ...