牛客多校第三场 B【Classical String Problem】
牛客多校第三场 B【Classical String Problem】
链接:https://ac.nowcoder.com/acm/contest/5668/B
来源:牛客网
题目描述
Given a string S consists of lower case letters. You’re going to perform Q operations one by one. Each operation can be one of the following two types:
Modify: Given an integer x. You need to modify S according to the value of x. If x is positive, move the leftmost x letters in S to the right side of S; otherwise, move the rightmost |x| letters in S to the left side of S.
Answer: Given a positive integer x. Please answer what the x-th letter in the current string S is.
输入描述:
There are Q+2 lines in the input. The first line of the input contains the string S. The second line contains the integer Q. The following Q lines each denotes an operation. You need to follow the order in the input when performing those operations.
Each operation in the input is represented by a character c and an integer x. If c = ‘M’, this operation is a modify operation, that is, to rearrange S according to the value of x; if c = ‘A’, this operation is an answer operation, to answer what the x-th letter in the current string S is.
• 2 \le |S| \le 2 \times 10^62≤∣S∣≤2×10
6
(|S| stands for the length of the string S)
• S consists of lower case letters
• 1 \le Q \le 8 \times 10^51≤Q≤8×10
5
• c = 'M' or 'A'
• If c = 'M', 1 \le |x| < |S|1≤∣x∣<∣S∣
• If c = 'A', 1 \le x \le |S|1≤x≤∣S∣
• There is at least one operation in the input satisfies c = 'A'
输出描述:
For each answer operation, please output a letter in a separate line representing the answer to the operation. The order of the output should match the order of the operations in the input.
示例1
输入
nowcoder
6
A 1
M 4
A 6
M -3
M 1
A 1
输出
n
o
w
找规律!!!暴力ttt
#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<string>#include<cmath>#include<stack>using namespace std;typedef long long ll;string a;int main(){ll len;ll k;char c;ll b,x=0,m=0;cin>>a;scanf("%lld",&k);len=a.size();for(int i=0;i<2*k;i++){scanf("%c %lld",&c,&b);if(c=='M'){x=m+b;if(x<0)x+=len;m=x%len;}//cout<<m;ll n;if(c=='A'){n=(m+b-1)%len;printf("%c\n",a[n]);}}return 0;}
牛客多校第三场 B【Classical String Problem】相关推荐
- exgcd ---- 2020牛客多校第三场:[Fraction Construction Problem:exgcd+思维题]
题目链接 题目大意:就是给你两个数a,ba,ba,b叫你求满足下面三个条件的c,d,e,fc,d,e,fc,d,e,f 1.cd−ef=ab1.{c\over d}-{e\over f}={a\ove ...
- 24dian(牛客多校第三场)
24dian(牛客多校第三场) 题意: 给你n张牌,每张牌的大小为1 ~ 13,问这些牌与加减乘除任意组合(可以使用括号),且但所有的有效解在计算过程中都涉及到分数,即非整数,能否组成答案m,如果可以 ...
- 牛客多校第四场【B-Basic Gcd Problem】
牛客多校第四场[B-Basic Gcd Problem] 题目链接:https://ac.nowcoder.com/acm/contest/5669/B 思路:先要理解公式,多看几个数据基本就会有点想 ...
- 牛客多校第三场A【Clam and fish】贪心
A[Clam and fish]贪心 链接:https://ac.nowcoder.com/acm/contest/5668/A 来源:牛客网 题目: There is a fishing game ...
- 2020牛客多校第三场[C Operation Love+基础计算几何 判断多边形顺逆时针]
题目链接 题目大意:就是给你两个左右手的模型,下面给出这两只手通过平移变换之后坐标问你这只手是左手还是右手?[题目保证坐标是按照顺时针或者逆时针给出的] 解题思路:首先我们先观察一下这只右手:假如数据 ...
- Splay ---- 2018牛客多校第三场 区间翻转搞区间位移 或者 rope可持久化块状链表
题目链接 题目大意: 就是每次把牌堆中若干个连续的牌放到堆顶,问你最后牌的序列. 解题思路: Splay 区间翻转的模板题: 对于一个区间[1,2,3,4,5,6,7,8][1,2,3,4,5,6,7 ...
- Math(牛客多校第三场)
Math 题意: 问你有多少对(x,y),1<=x<=y<=n,满足(x2 + y2)%(xy+1) == 0 题解: 这种题...直接打表芜湖~ 通过打表发现:满足情况的为(i,i ...
- 2019牛客多校第三场 F.Planting Trees
题目链接 题目链接 题解 题面上面很明显的提示了需要严格\(O(n^3)\)的算法. 先考虑一个过不了的做法,枚举右下角的\((x,y)\),然后二分矩形面积,枚举其中一边,则复杂度是\(O(n^3 ...
- 2019 牛客多校第三场 B Crazy Binary String
题目链接:https://ac.nowcoder.com/acm/contest/883/B 题目大意 给定一个长度为 N 的 01 字符串,输出最长子串和子序列的长度,满足其中 0 和 1 的个数相 ...
最新文章
- WCF .net Tcp 错误异常
- 华为锁屏后微信无法连接服务器,怎么解决华为p9锁屏收不到微信信息【教程详解】...
- 事务里面捕获异常_spring 事务回滚
- malloc,calloc和realloc函数
- HBase的布隆过滤器详解
- udp与tcp协议介绍
- c语言怎么读取mhx文件内容,C语言重新学习――基础杂类
- hibernate.validator验证参数
- linux grep的信息不全,Linux下grep显示前后几行信息方法介绍
- Python爬虫防封杀方法集合
- FastReport产品介绍及免费下载地址
- 读懂用户运营体系:用户分层和分群
- Excel生成指定范围内随机数
- CSS display 属性详解
- 解读Vue项目文件目录结构,实例化Vue对象,数据和方法
- 无法引用Microsoft.Office.Interop.Excel的解决
- 单细胞转录组实战01: CellRanger7定量
- HDS不玩了,高端存储还能玩多久?
- APICloud初使用记录
- GAMES101 作业0 环境配置 PC下简单配置i
热门文章
- ffmpeg_function: av_frame_get_best_effort_timestamp
- dayz哪些服务器物品是互通,DayZ服务器常用的一些武器食物吃喝子弹弹夹配件背包代码...
- 冷月虐哭数一之高等数学(1)-递归数列极限的求法和证明
- Linux将文件压缩成tgz格式,以及将tgz格式解压
- 历史上两个人合作的成功案例
- Spring详解二号AOP冰霜篇
- 什么是GNSS模拟器及其应用?
- What's wrong baby?
- Oracle推导参数Derived Parameter介绍
- Linux和unix之间的关系