AC自动机-题目集合

C++——AC自动机例题——文本生成器(JSOI2007) 文本生成器(JSOI2007) 题目描述 JSOI 交给队员 ZYX一个任务,编制一个称之为“文本生成器”的电脑软件: 该软件的使用者是一些低幼人群,他们现在使用的是 GW 文本生成器 v6 版。该软件可以随机生成一些文章——总是生成一篇长度固定且完全随机的文章—— 也就是说,生成的文章中每个字节都是完全随机的。 如果一篇文章中至少包含使用者们了解的一个单词,那么我们说这篇文章 阅读详情

 AC自动机-题目集合 模板

  如果你想要学习AC自动机,推荐一些学习资料.

学习可以看这篇博客 http://blog.youkuaiyun.com/niushuai666/article/details/7002823

或者看看大佬的视频讲解 http://www.bilibili.com/video/av6295004/

下面是一些AC自动机的一些入门题目.和AC代码,先学再做练习.


题目链接: hdu-2222

#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<set>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<time.h>

using namespace std;
typedef long long LL;
const int INF=2e9+1e8;
const int MOD=1e9+7;
const int MAXSIZE=1e6+5;
const double eps=0.0000000001;
void fre()
{
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
}
#define memst(a,b) memset(a,b,sizeof(a))
#define fr(i,a,n) for(int i=a;i<n;i++)

const int MAXNode=5e5+5;
struct Aho
{
    int ch[MAXNode][26]; // 多模式字符串 需要构建的 Tire(字典树)
    int last[MAXNode];   //  统计某一个模式串 (在Tire中MaxNode位置结尾的字符串) 个数,
    int fail[MAXNode]; //失配指针
    int sz,root;
    int newnode()
    {
        memset(ch[sz],-1,sizeof(ch[sz]));
        last[sz++]=0;
        return sz-1;
    }
    void init()
    {
        sz=0;
        root=newnode();
    }
    void insert(char *s)
    {
        int len=strlen(s);
        int now=root;
        for(int i=0; i<len; i++)
        {
            if(ch[now][s[i]-'a']==-1) ch[now][s[i]-'a']=newnode();
            now=ch[now][s[i]-'a'];
        }
        last[now]++;
    }
    void GetFail()// 如何构建失败指针,还是不太会.所以套 kuangbin 模板
    {
        queue<int>Q;
        fail[root]=root;
        for(int i = 0; i < 26; i++)
        {
            if(ch[root][i]==-1)
                ch[root][i]=root;
            else
            {
                fail[ch[root][i]]=root;
                Q.push(ch[root][i]);
            }
        }
        while(!Q.empty())
        {
            int now=Q.front();
            Q.pop();
            for(int i=0; i<26; i++)
            {
                if(ch[now][i]==-1)
                    ch[now][i]=ch[fail[now]][i];
                else
                {
                    fail[ch[now][i]]=ch[fail[now]][i];
                    Q.push(ch[now][i]);
                }
            }
        }
    }
    int match(char *s)
    {
        int len=strlen(s);
        int now=root;
        int res=0;
        for(int i=0; i<len; i++)
        {
            now=ch[now][s[i]-'a'];
            int temp=now;
            while(temp!=root)
            {
                res+=last[temp];
                last[temp]=0;
                temp=fail[temp];
            }
        }
        return res;
    }
} ac;
char str[MAXSIZE];
inline void read(int& ret) //适用于正整数
{
    char c;
    ret=0;
    while((c=getchar())<'0'||c>'9');
    while(c>='0'&&c<='9') ret=ret*10+(c-'0'),c=getchar();
}
int main(int argc,char *argv[])
{
    int ncase;
    read(ncase);
    while(ncase--)
    {
        int n;
        ac.init();
        scanf("%d",&n);
        for(int i=0; i<n; i++)
        {
            scanf("%s",str);
            ac.insert(str);
        }
        ac.GetFail();
        scanf("%s",str);
        printf("%d\n",ac.match(str));
    }
    return 0;
}

/**  http://blog.youkuaiyun.com/wr_technology  */


鄙人只是存模板,失配指针怎么构建,目前正在学习之中。若想要学习 AC自动机。请点这篇博文。总结的详细。


------------------------------------------  分割线  ---------------------------------------------------------


上面是kuangbin模板,不太会。因为他在构建fail指针的的时候不是最简单的方法。所以我又找了一另一个代码来学习,这一份就是朴素的方法,不像kuangbin模板优化过,不适合初学者。


#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<set>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<time.h>

using namespace std;
typedef long long LL;
const int INF=2e9+1e8;
const int MOD=1e9+7;
const int MAXSIZE=1e6+5;
const double eps=0.0000000001;
void fre()
{
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
}
#define memst(a,b) memset(a,b,sizeof(a))
#define fr(i,a,n) for(int i=a;i<n;i++)

const int MAXNode=5e5+5;
struct Aho
{
    int ch[MAXNode][26]; // 多模式字符串 需要构建的 Tire(字典树)
    int last[MAXNode];   //  统计某一个模式串 (在Tire中MaxNode位置结尾的字符串) 个数,
    int fail[MAXNode]; //失配指针
    int sz,root;
    int newnode()
    {
        memset(ch[sz],-1,sizeof(ch[sz]));
        last[sz++]=0;
        return sz-1;
    }
    void init()
    {
        sz=0;
        root=newnode();
    }
    void insert(char *s)
    {
        int len=strlen(s);
        int now=root;
        for(int i=0; i<len; i++)
        {
            if(ch[now][s[i]-'a']==-1) ch[now][s[i]-'a']=newnode();
            now=ch[now][s[i]-'a'];
        }
        last[now]++;
    }
    void GetFail()//
    {
        queue<int>Q;
        Q.push(root);
        while(!Q.empty())
        {
            int now=Q.front();
            Q.pop();
            for(int i=0;i<26;i++)
            {
                if(ch[now][i]!=-1)
                {
                    if(now==root) fail[ch[now][i]]=root;
                    else
                    {
                        int temp=fail[now];
                        while(temp&&ch[temp][i]==-1) temp=fail[temp];
                        fail[ch[now][i]]=ch[temp][i];
                    }
                    Q.push(ch[now][i]);
                }
            }
        }
        return ;
    }
    int match(char *s)
    {
        int len=strlen(s);
        int now=root,temp;
        int res=0;
        for(int i=0; i<len; i++)
        {

            while(now&&ch[now][s[i]-'a']==-1) 
                now=fail[now];temp=now=ch[now][s[i]-'a'];
            while(temp!=root)
            {
                res+=last[temp];
                last[temp]=0;
                temp=fail[temp];
            }
        }
        return res;
    }
} ac;
char str[MAXSIZE];
inline void read(int& ret)
{
    char c;
    ret=0;
    while((c=getchar())<'0'||c>'9');
    while(c>='0'&&c<='9') ret=ret*10+(c-'0'),c=getchar();
}
int main(int argc,char *argv[])
{
    int ncase;
    read(ncase);
    while(ncase--)
    {
        int n;
        ac.init();
        scanf("%d",&n);
        for(int i=0; i<n; i++)
        {
            scanf("%s",str);
            ac.insert(str);
        }
        ac.GetFail();
        scanf("%s",str);
        printf("%d\n",ac.match(str));
    }
    return 0;
}

/**  http://blog.youkuaiyun.com/wr_technology  */

------------------------------------------------------------------------------------------------------------------------------------------------------------

下面是 hdu-2896 

#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<set>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<time.h>
using namespace std;
typedef long long LL;
const int INF=2e9+1e8;
const int MOD=1e9+7;
const int MAXSIZE=1e6+5;
const double eps=0.0000000001;
void fre()
{
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
}
#define memst(a,b) memset(a,b,sizeof(a))
#define fr(i,a,n) for(int i=a;i<n;i++)
const int MAXNode=5e5+5;


int ans[10005][505],cnt[505];
struct Aho
{
    int ch[100000][128]; // 多模式字符串 需要构建的 Tire(字典树)
    int last[MAXNode];   //  统计某一个模式串 (在Tire中MaxNode位置结尾的字符串) 个数,
    int fail[MAXNode]; //失配指针
    int sz,root;
    int newnode()
    {
        memset(ch[sz],-1,sizeof(ch[sz]));
        last[sz++]=0;
        return sz-1;
    }
    void init()
    {
        sz=0;
        root=newnode();
    }
    void insert(char *s,int id)
    {
        int now=root;
        for(int i=0;  s[i]!='\0' ; i++)
        {
            if(ch[now][(int)s[i]]==-1) ch[now][(int)s[i]]=newnode();
            now=ch[now][(int)s[i]];
        }
        last[now]=id;
    }
    void GetFail()
    {
        queue<int>Q;
        Q.push(root);
        while(!Q.empty())
        {
            int now=Q.front();
            Q.pop();
            for(int i=0; i<128; i++)
            {
                if(ch[now][i]!=-1)
                {
                    if(now==root) fail[ch[now][i]]=root;
                    else
                    {
                        int temp=fail[now];
                        while(temp&&ch[temp][i]==-1) temp=fail[temp];
                        fail[ch[now][i]]=ch[temp][i];
                    }
                    Q.push(ch[now][i]);
                }
            }
        }
        return ;
    }
    void match(char *s,int id)
    {
        int  flag[550];
        memset(flag,0,sizeof(flag));
        int now=root,temp;
        for(int i=0; s[i]!='\0'; i++)
        {

            while(now&&ch[now][(int)s[i]]==-1)
                now=fail[now];
            temp=now=ch[now][(int)s[i]];
            while(temp!=root&&flag[last[temp]]==0)
            {
                if(last[temp])
                {
                    ans[id][cnt[id]++]=last[temp];
                    flag[last[temp]]=1;
                }
                temp=fail[temp];
            }
            if(cnt[id]>=3) break;
        }
        return ;
    }
} ac;
char str[MAXSIZE];
void print(int m)
{
    int sum=0;
    for(int i=1; i<=m; i++)
    {
        if(!cnt[i]) continue;
        printf("web %d:",i);
        for(int j=0; j<cnt[i]; j++) printf(" %d",ans[i][j]);
        printf("\n");
        sum++;
    }
    printf("total: %d\n",sum);
}

int main(int argc,char *argv[])
{
    int n,m;
    scanf("%d",&n);
    getchar();
    memset(cnt,0,sizeof(cnt));
    ac.init();
    for(int i=1; i<=n; i++)
    {
        gets(str);
        ac.insert(str,i);
    }
    ac.GetFail();
    scanf("%d",&m);
    getchar();
    for(int j=1; j<=m; j++)
    {
        scanf("%s",str);
        ac.match(str,j);
        sort(ans[j],ans[j]+cnt[j]);
    }
    print(m);
    return 0;
}

-----------------------------------------------------------------------------------------------------------------------


hihocoder-1036

#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<set>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<time.h>

using namespace std;
typedef long long LL;
const int INF=2e9+1e8;
const int MOD=1e9+7;
const int MAXSIZE=1e6+5;
const double eps=0.0000000001;
void fre()
{
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
}
#define memst(a,b) memset(a,b,sizeof(a))
#define fr(i,a,n) for(int i=a;i<n;i++)

const int MAXNode=5e6+5;

struct Aho
{
    int ch[MAXNode][26],fail[MAXNode],last[MAXNode],root,sz;
    int newnode()
    {
        memset(ch[sz],-1,sizeof(ch[sz]));
        last[sz++]=0;
        return sz-1;
    }
    void init()
    {
        sz=0;
        root=newnode();
    }
    void insert(char *s)
    {
        int now=root;
        for(int i=0; s[i]!='\0'; i++)
        {
            int id=(int)(s[i]-'a');
            if(ch[now][id]==-1) ch[now][id]=newnode();
            now=ch[now][id];
        }
        last[now]=1;
    }
    void GetFail()
    {
        queue<int>Q;
        fail[root]=root;
        Q.push(root);
        while(!Q.empty())
        {
            int now=Q.front();
            Q.pop();
            for(int i=0; i<26; i++)
            {
                if(now==root)
                {
                    if(ch[now][i]==-1) ch[now][i]=root;
                    else fail[ch[now][i]]=root,Q.push(ch[now][i]);
                }
                else
                {
                    if(ch[now][i]==-1) ch[now][i]=ch[fail[now]][i];
                    else fail[ch[now][i]]=ch[fail[now]][i],Q.push(ch[now][i]);
                }
            }
        }
    }
    bool match(char *s)
    {
        int now=root;
        for(int i=0; s[i]!='\0'; i++)
        {
            now=ch[now][(int)(s[i]-'a')];
            if(last[now]) return true;
        }
        return false;
    }
} ac;
char str[MAXSIZE];
int main()
{
    int n;
    cin>>n;
    ac.init();
    for(int i=0; i<n; i++)
    {
        scanf("%s",str);
        ac.insert(str);
    }
    scanf("%s",str);
    ac.GetFail();
    if(ac.match(str)) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}





微信小程序 - 实现Java微信支付退款功能以及退款流程,微信小程序前端+java后端完整示例源码,微信小程序退款功能详解,小程序订单申请退款和退款回调方法、查询退款等(新版微信支付,详细示例代码) 微信小程序开发-微信支付退款功能以及退款回调方法,微信支付退款API详解,微信小程序支付V3(支付、退款)Java实现微信小程序开发 小程序支付开发-小程序退款功能,微信小程序小程序和公众号 退款功能教程(含申请退款和退款回调,退款回调地址在商户后台配置或者代码自定义)最新版微信小程序支付,退款问题,小程序支付和退款功能详解,小程序申请退款,小程序处理退款,微信小程序支付与退款java,微信小程序退款及回调,JAVA实现微信小程序支付退款功能,退款api调用报错,如何解决退款申请无响应,如何用实现小程序订单 阅读详情

相关推荐

【NVIDIA驱动的顽固问题】---- /dev/sdax:clean,xxx/xxx files,xxx/xxx blocks ---- 最全解决方法

本文的意义在于整理总结关于此问题的全部解决方法,希望能给大家节约时间。

lc1852109的博客 3128

AC自动机详解,原理、优化分析,代码实现

填坑ing

EQUINOX1的博客 9489

EGO_Plannerv2代码学习(一):栅格建图之V1 V2的区别

最近在尝试将高飞老师的集群规划器部署到真实无人机上跑一下,开这个新帖记录下学习过程中的问题和想法。

qq_41069236的博客 5753

关于 AC 自动机

AC 自动机,全称 Aho-Corasick 自动机,是一种用于字符串搜索的算法,由 Alfred V. Aho 和 Margaret J. Corasick 在 1975 年提出。这个算法是为了解决在一个主文本字符串中查找多个模式字符串(或称为“关键词”)的问题,它可以在线性时间内完成搜索,非常高效。在计算机科学中,Aho-Corasick 算法是 Alfred V. Aho 和 Margaret J. Corasick 于 1975 年发明的一种字符串搜索算法。

weixin_43501634的博客 5445

Verilog实战:手把手教你实现四路组相联Cache(附完整代码解析)

本文提供了一份详细的Verilog实战指南,手把手教你实现一个四路组相联Cache。内容涵盖从设计规格、核心存储阵列、LRU替换策略到状态机设计的完整流程,并附有代码解析与优化技巧,旨在帮助硬件设计者掌握Cache控制器的RTL实现与调试方法。

pp12345的博客 517

Starlink第三代终端和第二代终端的差异性有哪些?

starlink第三代终端和第二代终端的额差异

chen2jiang3的博客 2929

浅谈 AC 自动机

省流:比后缀数组还要简单的 AC 自动机!!

WerChange的OI博客 2893

利用eds editor生成CANOPEN 设备eds文件

通过以上步骤,您可以根据实际设备的功能特性,自动生成一份符合CANopen协议标准的电子数据表(EDS文件),该文件可以被上位机软件或其他CANopen主站设备用于识别、配置和控制您的CANopen从站设备。使用CANopen EDS Editor生成CANOPEN设备的EDS文件是一个系统化的过程,它涉及将设备的具体技术参数和功能映射到CANopen规范定义的对象字典中。

weixin_38604759的博客 6459

ac自动机

下面开始用图学习ac自动机吧(个人比较喜欢放图,能用一张图解决的绝不叨叨) 首先给定模式串"ash","shex","bcd","sha",然后我们根据模式串建立如下trie树: 然后我们再了解下一步: ac自动机,就是在tire树的基础上,增加一个fail指针,如果当前点匹配失败,则将指针转移到fail指针指向的地方,这样就不用回溯,而可以路匹配下去了.(当前模式串后缀和fail指针指向的...

Insistor 715

PVE启动卡在loading initial ramdisk

pve显卡直通导致的异常解决

学而时习之 6691

别再让步进电机‘发烧’了!用FOC闭环驱动实现精准力矩控制(基于P0斩波恒流版)

本文详细介绍了如何利用FOC闭环驱动技术(基于P0斩波恒流版)解决步进电机过热和力矩控制不精准的问题。通过对比传统开环控制的缺陷,展示了FOC在降低温度、提升精度和能效方面的显著优势,并提供了硬件配置、软件实现及性能优化的完整方案。

weixin_30872157的博客 567

C++算法 - AC自动机

AC自动机用于匹配字符串中的多模式串问题,将所有模式串转换为一个字典树,再用广度优先搜索算法构建出字典树每个结点的失配指针,最后通过搜索主串来匹配主串中包含的模式串个数。

LNY2022的博客 2426

26 硬件工程师笔面试高频考点真题解析——CAN总线

CAN总线是一种差分多主串行半双工总线,采用非破坏性位仲裁机制和五层硬件错误检测(位错误、填充错误、CRC校验、格式错误、应答错误),具有高可靠性和故障容错能力。关键设计包括两端120Ω终端电阻匹配阻抗、手拉手总线拓扑、显性/隐性电平优先级仲裁。常见故障分析指出多节点异常多因终端电阻错配/漏装、星型布线违规或总线过载;高速通讯失败常由阻抗失配或线缆过长导致信号反射。相比RS485,CAN支持多主架构、硬件自动仲裁和节点故障隔离,更适用于汽车、工业等高可靠场景。

XU157303764的博客 550

牛客网暑期ACM多校训练营(第九场) F Typing practice(AC自动机)

题目链接:https://www.nowcoder.com/acm/contest/147/F 牛客网 感谢:https://blog.youkuaiyun.com/LSD20164388/article/details/81778591 题目描述 Niuniu is practicing typing.Given n words, Niuniu want to input one of t...

weixin_33849215的博客 142

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

hdu2222 AC自动机

题目链接:点击打开链接 题意: 给n个字串,问文章中有多少个字串; 理解: 这是一个多模式串匹配问题; 和KMP单模式串匹配不同; 用AC自动机即可解决; AC自动机:点击打开链接 上面链接写的很好; 对于AC自动机其实不难,主要在要做好失败指针; 其实这个比KMP还容易理解; 其目的就是找一个后缀相同的串; 第一道AC自动机的题; 留作纪念

追求和名字一样的级别 334

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

AC自动机入门 - HDU3065 病毒侵袭持续中

AC自动机的模板题。 HDU3065 病毒侵袭持续中 题意:给定n个字符串和一段文本,统计每个字符串在文本中分别出现的次数。 注意点:这里输入单词的时候给每个单词分布一个id,然后在统计次数的时候根据id增加数组的次数就可以了。(这里用kuangbin大神的模板) code: #include #include #include #include using namespa

Exchan 384

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

BZOJ3881[Coci2015]Divljak——AC自动机+树状数组+LCA+dfs序+树链的并

题目描述 Alice有n个字符串S_1,S_2...S_n,Bob有一个字符串集合T,一开始集合是空的。 接下来会发生q个操作,操作有两种形式: “1 P”,Bob往自己的集合里添加了一个字符串P。 “2 x”,Alice询问Bob,集合T中有多少个字符串包含串S_x。(我们称串A包含串B,当且仅当B是A的子串) Bob遇到了困难,需要你的帮助。 输入 第1行,一个数n;...

weixin_30604651的博客 74

HDU 6086 AC自动机+状压dp

题意:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6086 给出m个单词,要构造出长度为2*L的包含这全部m个单词的字符串,并且保证这个字符串非对称,其中字符只包括0和1,问一共有多少种构造方法。思路:本题是hdu2825的拓展,建议先做2825,博客链接:http://blog.youkuaiyun.com/bahuia/article/details/77

Bahuia的博客 1616

Codeforces 696D Legen...(AC自动机+矩阵快速幂)

http://codeforces.com/problemset/problem/696/D题意:给你n个串,每个串有个开心值,然后让你构造一个长为l的串,使得开心值之和最大。 题解:AC自动机处理这些串,然后开心值加在终止节点上,可能同一个节点有多个串,开心值就要加起来,然后bfs建立trie图的时候,要把失配之后的节点的开心值也要加到这个节点上,这样就不会漏掉了。 然后对于矩阵的每个节点i,

Miracle_ma的专栏 1290

HDU 6138 Fleet of the Eternal Throne AC自动机||后缀数组

传送门:HDU6138 题意:给出n个串和q次询问,每次询问给出x和y,表示输入的第x个和第y个串,要求找出一个最长的子串p,满足:p是x的子串,p是y的子串,且p是这n个串中某一个(可以是多个)的前缀,问p的最大长度是多少。 思路:看官方题解还很麻烦的样子,不过看dalao们的思路一下就懂了。。 将所有串插入到AC自动机里去,然后对于每个询问,先在AC自动机上查询x串,并对每一个经过的节点

WA是一笔财富 319

串 2016Vijos省选集训 day3[AC自动机]

1、串(string.c/.cpp/.pas) 限时1s,内存限制256MB,20个测试点 【题目描述】 兔子们在玩字符串的游戏。首先,它们拿出了一个字符串集合S,然后它们定义一个字符串为“好”的,当且仅当它可以被分成非空的两段,其中每一段都是字符串集合S中某个字符串的前缀。 比如对于字符串集合{"abc", "bca"},字符串"abb","abab"是“好”的("abb" ...

weixin_34407348的博客 141

2017多校第8场 HDU 6138 Fleet of the Eternal Throne AC自动机或者KMP

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6138 题意:给n个串,每次询问x号串和y号串的最长公共子串的长度,这个子串必须是n个串中某个串的前缀 解法1:AC自动机。做法是把n个串建成AC自动机,前缀树中每个节点都当做结尾节点,val赋为trie树深度,然后把x串丢进自动机里,把匹配到的前缀节点染个色,再把y串丢进去,遇到同样颜色...

aishangg437965的博客 130

[bzoj3530][Sdoi2014]数数_AC自动机_数位dp

数数 bzoj-3530 Sdoi-2014 题目大意:给你一个整数集合,求所有不超过n的正整数,是的它的十进制表示下不能再一段等于集合中的任意数。 注释:$1\le n \le 1200$,$1\le |S|\le 100$,$1\le L\le 1500$,L是总长度之和。 想法:咳咳,显然,我们... ...什么都不想,看着能开下先把AC自动机扔出来 然后,其实数位dp就可以了 具...

weixin_30888707的博客 120

hdu2825 AC自动机+状压dp

hdu2825 AC自动机和状压dp

m0_54646258的博客 201

单词 黑暗爆炸 - 3172(AC自动机+ 拓扑dp)

题目链接 Description 某人读论文,一篇论文是由许多单词组成。但他发现一个单词会在论文中出现很多次,现在想知道每个单词分别在论文中出现多少次。 Input 第一个一个整数 N, 表示有多少个单词,接下来 N 行每行一个单词。每个单词由小写字母组成,N<=200, 单词长度不超过 10^6 Output 输出 N 个整数,第 i 行的数字表示第 i 个单词在文章中出现了多少次。 Sample Input 3 a aa aaa Sample Output 6 3 1 题意 给我们 n 个字

做一只熊猫不好吗? 122
上一篇: codeforces-724
下一篇: nyoj 86 --位标记
Code--Dream
博客等级 码龄11年 53粉丝 100原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值