Description

给你一个字符串ss,共有qq次操作,每个都是下面两种形式的一种。

11 ii cc

这个操作表示将字符串ss的第ii项变为字符cc

22 ll rr yy

这个操作表示输出字符串yy在字符串ss中以第ll项为起点,以第rr项为终点的子串(包括第ll和第rr项)中作为子串出现的次数。

Solution

BZOJ 4503一样

稍微改改

Code

#include <bitset>
#include <string>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
const int N = 100005; std:: bitset<N> A[26];
int main () {
std:: string S;
std:: cin >> S;
for (int i = 0; i < S.size(); i += 1)
A[S[i] - 'a'].set(i);
int n;
scanf("%d", &n);
std:: string str;
while (n --) {
int opt, l, r;
scanf("%d%d", &opt, &l);
l -= 1;
if (opt == 1) {
std:: cin >> str;
A[S[l] - 'a'].reset(l);
S[l] = str[0];
A[S[l] - 'a'].set(l);
}
else {
scanf("%d", &r);
r -= 1;
std:: cin >> str;
std:: bitset<N> res;
res.set();
for (int i = 0; i < str.size(); i += 1)
res &= (A[str[i] - 'a'] >> i);
r = r - str.size() + 1;
printf("%d\n", std:: max(0, (int)((res >> l).count() - (res >> r + 1).count())));
}
}
return 0;
}

CF914F Substrings in a String的更多相关文章

  1. cf914F. Substrings in a String(bitset 字符串匹配)

    题意 题目链接 Sol Orz jry 和上一个题一个思路吧,直接bitset乱搞,不同的是这次有了修改操作 因为每次修改只会改两个位置,直接暴力改就好了 #include<bits/stdc+ ...

  2. 【CodeForces】914 F. Substrings in a String bitset

    [题目]F. Substrings in a String [题意]给定小写字母字符串s,支持两种操作:1.修改某个位置的字符,2.给定字符串y,查询区间[l,r]内出现y多少次.|s|,Σ|y|&l ...

  3. [LeetCode] Unique Substrings in Wraparound String 封装字符串中的独特子字符串

    Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...

  4. Leetcode: Unique Substrings in Wraparound String

    Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...

  5. [Swift]LeetCode467. 环绕字符串中唯一的子字符串 | Unique Substrings in Wraparound String

    Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...

  6. 动态规划-独特的子字符串存在于Wraparound String总个数 Unique Substrings in Wraparound String

    2018-09-01 22:50:59 问题描述: 问题求解: 如果单纯的遍历判断,那么如何去重保证unique是一个很困难的事情,事实上最初我就困在了这个点上. 后来发现是一个动态规划的问题,可以将 ...

  7. 467. Unique Substrings in Wraparound String

    Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...

  8. LeetCode 467. Unique Substrings in Wraparound String

    Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...

  9. 【LeetCode】467. Unique Substrings in Wraparound String

    Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...

随机推荐

  1. BZOJ2816:[ZJOI2012]网络——题解

    https://www.lydsy.com/JudgeOnline/problem.php?id=2816 https://www.luogu.org/problemnew/show/P2173 有一 ...

  2. 微软TTS语音引擎编程入门

    原文链接地址:http://www.jizhuomi.com/software/135.html   我们都使用过一些某某词霸的英语学习工具软件,它们大多都有朗读的功能,其实这就是利用的Windows ...

  3. 玩(lay) 解题报告

    玩(lay) 题目名称 你的昆特牌打的太好啦!不一会你就 \(\tt{AK}\) 了 \(\tt{NOGP}\),只能无聊地堆牌玩! 题目描述 你有一些矩形卡牌,每次你会作如下三个操作: 紧挨着最后一 ...

  4. hdu5652:India and China Origins(并查集)

    倒序操作用并查集判断是否连通,新技能get√(其实以前就会了 这题细节很多...搞得整个程序都是调试输出,几度看不下去想要重写 并查集到现在大概掌握了两个基本用途:判断是否连通 / 路径压缩(上一篇b ...

  5. 最近经历的一些大数据(Spark/Hadoop)面试题

    1.简答说一下hadoop的map-reduce编程模型 首先map task会从本地文件系统读取数据,转换成key-value形式的键值对集合 使用的是hadoop内置的数据类型,比如longwri ...

  6. ACE反应器(Reactor)模式(2)

    转载于:http://www.cnblogs.com/TianFang/archive/2006/12/18/595808.html 在Socket编程中,常见的事件就是"读就绪" ...

  7. HDU 2136 素数打表+求质数因子

    Largest prime factor Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  8. [dhcpd]清除dhcp缓存

    修改了dhcp的default-lease-time && max-lease-time 清除缓存: rm /var/lib/dhcpd.leases~ echo "&quo ...

  9. Qt -------- 容器类

    QVector(数组).QLinkedList(链表).QMap(映射表).QHash(哈希表).QQueue(队列) QHash遍历举例: 法1: QThread& ThreadHandle ...

  10. springboot-用logback将日志文件按等级保存到不同文件

    springboot-用logback将日志文件按等级保存到不同文件 案例: 例如项目基本包名为com.xxx,将该包下的所有日志按debug.info.warn.error等级分别保存到D:/log ...