zoukankan      html  css  js  c++  java
  • 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
    ", std:: max(0, (int)((res >> l).count() - (res >> r + 1).count())));
            }
        }
        return 0;
    }
    
  • 相关阅读:
    xgzc— math 专题训练(一)
    floyd判圈算法
    CF961G Partitions
    luoguP4778 Counting swaps
    AT3913 XOR Tree(巧妙转换+状压dp)
    手动实现aop编程
    代理模式
    spring重点一:处理对象创建时间 个数以及方式
    spring helloword
    spring用来干什么,解决的问题
  • 原文地址:https://www.cnblogs.com/qdscwyy/p/9774754.html
Copyright © 2011-2022 走看看