• shift and算法


    1. CF 914F Substrings in a String

    大意: 给定一个串s, q个询问, (1)单点修改, (2)询问[l,r]范围内串y的出现次数.

    shift and算法板子题

    #pragma GCC optimize("Ofast")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #pragma GCC optimize("unroll-loops")
    #include <iostream>
    #include <iostream>
    #include <algorithm>
    #include <cstdio>
    #include <math.h>
    #include <set>
    #include <map>
    #include <queue>
    #include <string>
    #include <string.h>
    #include <bitset>
    #define REP(i,a,n) for(int i=a;i<=n;++i)
    #define PER(i,a,n) for(int i=n;i>=a;--i)
    #define hr putchar(10)
    #define pb push_back
    #define lc (o<<1)
    #define rc (lc|1)
    #define mid ((l+r)>>1)
    #define ls lc,l,mid
    #define rs rc,mid+1,r
    #define x first
    #define y second
    #define io std::ios::sync_with_stdio(false)
    #define endl '
    '
    #define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
    using namespace std;
    typedef long long ll;
    typedef pair<int,int> pii;
    const int P = 1e9+7, INF = 0x3f3f3f3f;
    ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
    ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
    ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
    inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
    //head
    
    
    
    #ifdef ONLINE_JUDGE
    const int N = 1e5+10;
    #else
    const int N = 11;
    #endif
    
    int n, m;
    char s[N], buf[N];
    bitset<N> ch[26], ans;
    
    int main() {
    	scanf("%s", s);
    	n = strlen(s);
    	REP(i,0,n-1) ch[s[i]-'a'].set(i);
    	scanf("%d", &m);
    	REP(i,1,m) {
    		int op, x, y;
    		char c;
    		scanf("%d%d", &op, &x),--x;
    		if (op==1) {
    			scanf(" %c", &c);
    			ch[s[x]-'a'].reset(x);
    			s[x] = c;
    			ch[s[x]-'a'].set(x);
    		}
    		else {
    			scanf("%d%s", &y, buf),--y;
    			int len = strlen(buf);
    			if (y-x+1<len) {
    				puts("0");
    				continue;
    			}
    			ans.set();
    			REP(i,0,len-1) ans&=ch[buf[i]-'a']>>i;
    			int ret = (ans>>x).count()-(ans>>y-len+2).count();
    			printf("%d
    ", ret);
    		}
    	}
    }
    
  • 相关阅读:
    Oracle Dataguard管理命令(logical standby)
    RAC 主库配置单实例ADG
    基于参数shared_pool_reserved_size进一步理解共享池shared pool原理
    线性表的本质和操作
    类族结构的进化
    顶层父类的创建
    异常类的构建——5个子类构建
    异常类的构建——顶层父类Exception的实现
    智能指针示例
    泛型编程简介
  • 原文地址:https://www.cnblogs.com/uid001/p/10770983.html
Copyright © 2020-2023  润新知