CF914F Substrings in a String
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的更多相关文章
- cf914F. Substrings in a String(bitset 字符串匹配)
题意 题目链接 Sol Orz jry 和上一个题一个思路吧,直接bitset乱搞,不同的是这次有了修改操作 因为每次修改只会改两个位置,直接暴力改就好了 #include<bits/stdc+ ...
- 【CodeForces】914 F. Substrings in a String bitset
[题目]F. Substrings in a String [题意]给定小写字母字符串s,支持两种操作:1.修改某个位置的字符,2.给定字符串y,查询区间[l,r]内出现y多少次.|s|,Σ|y|&l ...
- [LeetCode] Unique Substrings in Wraparound String 封装字符串中的独特子字符串
Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...
- Leetcode: Unique Substrings in Wraparound String
Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...
- [Swift]LeetCode467. 环绕字符串中唯一的子字符串 | Unique Substrings in Wraparound String
Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...
- 动态规划-独特的子字符串存在于Wraparound String总个数 Unique Substrings in Wraparound String
2018-09-01 22:50:59 问题描述: 问题求解: 如果单纯的遍历判断,那么如何去重保证unique是一个很困难的事情,事实上最初我就困在了这个点上. 后来发现是一个动态规划的问题,可以将 ...
- 467. Unique Substrings in Wraparound String
Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...
- LeetCode 467. Unique Substrings in Wraparound String
Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...
- 【LeetCode】467. Unique Substrings in Wraparound String
Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...
随机推荐
- BZOJ1491 洛谷2047 NOI2007 社交网络
Description: 在社交网络(social network)的研究中,我们常常使用图论概念去解释一些社会现象.不妨看这样的一个问题.在一个社交圈子里有n个人,人与人之间有不同程度的关系.我 们 ...
- php 获取客户端IP地址经纬度所在城市
1. [代码]获取客户端IP地址经纬度所在城市 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 <?php $getIp=$_SERVER["REMOTE_ADDR ...
- 使用rsyslog编程,产生trace信息,记录到日志中
参考:http://blog.csdn.net/nowayings/article/details/38926501 https://www.cnblogs.com/bonelee/p/6234647 ...
- [存一下]iptables模块
介绍地址: http://www.tummy.com/blogs/2005/07/17/some-iptables-modules-you-probably-dont-know-about/ [1] ...
- POJ 2289 最大流
Jamie's Contact Groups Time Limit: 7000MS Memory Limit: 65536K Total Submissions: 7624 Accepted: ...
- [LeetCode] 5. Longest Palindromic Substring ☆☆☆☆
Given a string s, find the longest palindromic substring in s. You may assume that the maximum lengt ...
- Spring 学习笔记之整合Hibernate
Spring和Hibernate处于不同的层次,Spring关心的是业务逻辑之间的组合关系,Spring提供了对他们的强大的管理能力, 而Hibernate完成了OR的映射,使开发人员不用再去关心SQ ...
- 【BZOJ4373】算术天才⑨与等差数列 [线段树]
算术天才⑨与等差数列 Time Limit: 10 Sec Memory Limit: 128 MB[Submit][Status][Discuss] Description 算术天才⑨非常喜欢和等 ...
- 【BZOJ4870】组合数问题 [矩阵乘法][DP]
组合数问题 Time Limit: 10 Sec Memory Limit: 512 MB[Submit][Status][Discuss] Description Input 第一行有四个整数 n ...
- Ubuntu中启用关闭Network-manager网络设置问题! 【Server版本】
在UbuntuServer版本中,因为只存有命令行模式,所以要想进行网络参数设置,只能通过修改/etc/network/interfaces.具体设置方法如下: (1) UbuntuServer 修改 ...