cf Queries on a String
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define maxn 200005
char s[maxn];
int nxt[maxn][],ans[maxn],t[maxn];
int main(){
int q;
scanf("%s %d",s+,&q);
int n=strlen(s+);
memset(nxt[n],-,sizeof nxt[n]);
for(int i=n-;i>=;i--)
for(int j=;j<;j++)
if(s[i+]-'a'==j) nxt[i][j]=i+;//下一个 'a'+j 在字符串的第i+1个位置
else nxt[i][j]=nxt[i+][j];//下一个'a'+j字符在字符串的nxt[i+1][j]个位置 int len=;
char op[],c;
t[]=;
while(q--){
scanf("%s",op);
if(op[]=='s'){
cin >> c;
if(t[len-]==-) t[len]=-;
else t[len]=nxt[t[len-]][c-'a'];
len++;
}
else len--;
if(t[len-]!=-) puts("YES");
else puts("NO");
}
return ;
}
cf Queries on a String的更多相关文章
- CF 628C --- Bear and String Distance --- 简单贪心
CF 628C 题目大意:给定一个长度为n(n < 10^5)的只含小写字母的字符串,以及一个数d,定义字符的dis--dis(ch1, ch2)为两个字符之差, 两个串的dis为各个位置上字符 ...
- Educational Codeforces Round 1 B. Queries on a String 暴力
B. Queries on a String Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/59 ...
- 「CodeForces - 598B」Queries on a String
BUPT 2017 summer training (for 16) #1I 题意 字符串s(1 ≤ |s| ≤ 10 000),有m(1 ≤ m ≤ 300)次操作,每次给l,r,k,代表将r位置插 ...
- codeforces 598B Queries on a String
题目链接:http://codeforces.com/problemset/problem/598/B 题目分类:字符串 题意:给定一个串,然后n次旋转,每次给l,r,k,表示区间l到r的字符进行k次 ...
- CF 494B 【Obsessive String】
很有趣的一道题 这道题提议很难懂,其实就是让你求合法的集合数目.合法的集合定义为: 1.集合中的所有串都是s的子串,且互不重叠 2.集合中的所有串都含有子串t. 看到网上很多题解说要用kmp,但我就不 ...
- CF - 1117 F Crisp String
题目传送门 题解: 枚举非法对. 如果 ‘a' 和 ’b' 不能相邻的话,那么删除 'a' 'b'之间的字符就是非法操作了. 假设题目给定的字符串为 "acdbe",所以删除cd ...
- Codeforces Round #590 (Div. 3) D. Distinct Characters Queries(线段树, 位运算)
链接: https://codeforces.com/contest/1234/problem/D 题意: You are given a string s consisting of lowerca ...
- [转载]config文件的一个很好的实现
以下是转载于网上的一个很好的config文件的实现,留存以备案 //Config.h #pragma once #include <string> #include <map> ...
- Spring整合HBase
Spring整合HBase Spring HBase SHDP § 系统环境 § 配置HBase运行环境 § 配置Hadoop § 配置HBase § 启动Hadoop和HBase § 创建Maven ...
随机推荐
- java实现word转pdf在线预览(前端使用PDF.js;后端使用openoffice、aspose)
背景 之前一直是用户点击下载word文件到本地,然后使用office或者wps打开.需求优化,要实现可以直接在线预览,无需下载到本地然后再打开. 随后开始上网找资料,网上资料一大堆,方案也各有不同,大 ...
- Kafka 0.10问题点滴
15.如何消费内部topic: __consumer_offsets 主要是要让它来格式化:GroupMetadataManager.OffsetsMessageFormatter 最后用看了它的源码 ...
- kudu记录-kudu原理
1.kudu是什么? 2.kudu基本概念 特点: High availability(高可用性).Tablet server 和 Master 使用 Raft Consensus Algorith ...
- oracle解除锁表【原】
在日常操作中,经常会有不小心被锁表的情况发生 一般造成原因有: 开发人员不小心执行了 for update 查询语句后,没有解锁 不合理代码中开启事务(begin transaction)后,没有关闭 ...
- ThinkPHP 3.2 vendor()方法的深入研究及Phpqrcode的正确扩展
ThinkPHP vendor 方法导入第三方类库 第三方类库 第三方类库指除了 ThinkPHP 框架.应用项目类库之外的其他类库,一般由第三方系统或产品提供,如 Smarty.Zend 等系统的类 ...
- Shell + crontab 实现日志压缩归档
Shell + crontab 实现日志压缩归档 crontab # archive the ats log days. */ * * * * root /bin/>& shell #! ...
- 8.SpringBoot 模板引擎 Thymeleaf
1.模板引擎原理 JSP.Velocity.Freemarker.Thymeleaf 都是模板引擎.SpringBoot推荐的Thymeleaf:语法更简单,功能更强大: Thymeleaf模板引擎 ...
- QA系统Match-LSTM代码研读
QA系统Match-LSTM代码研读 背景 在QA模型中,Match-LSTM是较早提出的,使用Prt-Net边界模型.本文是对阅读其实现代码的总结.主要思路是对照着论文和代码,对论文中模型的关键结构 ...
- OracleHelper与SqlServerHelper
1.OracleHelper using System; using System.Data; using System.Configuration; using System.Linq; using ...
- avloadingindicatorview 使用解析
官方文档:https://github.com/81813780/AVLoadingIndicatorView 中文文档:https://www.helplib.com/GitHub/article_ ...