POJ-4052-ac自动机

西电2023秋季机器学习复习提纲 西电2023秋季机器学习复习提纲,希望对学弟学妹有帮助 阅读详情

先把匹配上的串都标记。然后把每个匹配上的串的子串变成非结束。

直接会超时。优化找失败指针的地方。


#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;

const int maxn = 250009;

char str1[5100009], str2[5100009]; 
char s[2509][1109];
char ss[1109];
int vis[maxn];
int cnt, n;

struct trie
{
    trie *ch[26];
    trie *fail;
    int end, key;
    void init()
    {
        memset(ch, NULL, sizeof(ch));
        fail = NULL;
        key = 0;
    }
}*root, t[maxn];

void insert(char *s, int id) //正常的插入
{
    trie *p = root;
    for(int i=0; s[i]; i++)
    {
        int k = s[i]-'A';
        if(p->ch[k]==NULL)
        {
            t[cnt].init();
            p->ch[k] = &t[cnt++];
        }
        p = p->ch[k];
    }
    p->end = id;
    p->key = 1;
}

void reinsert(char *a) //将其子串删掉
{
    trie *p = root;
    for(int i=0; a[i]; i++)
    {
        int k = a[i]-'A';
        while(p->ch[k]==NULL && p!=root) p=p->fail;
        p = p->ch[k];
        p = (p==NULL)? root : p;
        trie *tmp = p;

        while(tmp!=root && tmp->key!=-3)
        {
            if(abs(tmp->key)==1 && vis[tmp->end])
            {
                vis[tmp->end] = 0;
            }
            tmp->key = -3;
            tmp = tmp->fail;
        }
    }
}

queue<trie*>q;
void build_fail()
{
    q.push(root);
    root->fail = root;
    while(!q.empty())
    {
        trie *p = q.front();
        q.pop();
        for(int k=0; k<26; k++)
        if(p->ch[k]!=NULL)
        {
            q.push(p->ch[k]);
            if(p==root)
            {
                p->ch[k]->fail = root;
                continue;
            }
            trie *tmp = p->fail;
            while( tmp!=root && tmp->ch[k]==NULL)
                tmp = tmp->fail;
            if(tmp->ch[k]) p->ch[k]->fail = tmp->ch[k];
            else p->ch[k]->fail = root;
        }
    }
}

void query(char *a) //标记出现过的所有串
{
    trie *p = root;
    for(int i=0; a[i]; i++)
    {
        int k = a[i]-'A';
        while(p->ch[k]==NULL && p!=root) p=p->fail;
        p = p->ch[k];
        p = (p==NULL)? root : p;
        trie *tmp = p;

        while(tmp!=root && tmp->key>=0)
        {
            if(tmp->key==1)
            {
                vis[tmp->end] = 1;
                tmp->key = -1;
            }
            else tmp->key = -2;
            tmp = tmp->fail;
        }
    }
}

int requery(char *a) 
{
    int ans = 0;
    trie *p = root;
    for(int i=0; a[i]; i++)
    {
        int k = a[i]-'A';
        while(p->ch[k]==NULL && p!=root) p=p->fail;
        p = p->ch[k];
        p = (p==NULL)? root : p;
        trie *tmp = p;
        while(tmp!=root && tmp->key!=-4)
        {
            if(abs(tmp->key)==1) ans++;
            tmp->key = -4;
            tmp = tmp->fail;
        }
    }
    return ans;
}

int main()
{
    int tt, i, j, k;
    scanf("%d", &tt);
    while(tt--)
    {
        cnt = 1;
        t[0].init();
        root = &t[0];
        scanf("%d", &n);
        for(i = 1; i<=n; i++)
        {
            scanf("%s", ss);
            for(k=0, j=0; ss[k]; k++)
            {
                if(ss[k]>='A' && ss[k]<='Z')
                {
                    s[i][j] = ss[k];
                    j++;
                }
                else
                {
                    k++;
                    int kk = ss[k]-'0';
                    k++;
                    while(ss[k]>='0'&&ss[k]<='9') kk = kk*10+ ss[k++]-'0';
                    while(kk--) s[i][j++] = ss[k];
                    k++;
                }
            }
            s[i][j] = '\0';
            insert(s[i], i);
        }
        build_fail();

        scanf("%s", str1);
        for(i=0, j=0; str1[i]; i++)
        {
            if(str1[i]>='A' && str1[i]<='Z')
            {
                str2[j] = str1[i];
                j++;
            }
            else
            {
                i++;
                int k = str1[i]-'0';
                i++;
                while(str1[i]>='0'&&str1[i]<='9') k = k*10+ str1[i++]-'0';
                while(k--) str2[j++] = str1[i];
                i++;
            }
        }
        str2[j] = '\0';
        memset(vis, 0, sizeof(vis));
        query(str2);

        for(int i=1; i<=n; i++)
        if(vis[i])
        {
            reinsert( s[i] );
            insert( s[i], i );
        }

        int ans = requery( str2 );
        printf("%d\n", ans);
    }
	return 0;
}


从AP到ADSP:高通8650 AudioReach中GSL-Passthru-GPR的数据通路剖析 本文深入剖析了高通骁龙8650平台AudioReach架构中,音频数据从应用处理器(AP)到音频数字信号处理器(ADSP)的完整传输路径。重点解析了GSL(Graph Service Layer)如何封装命令,并通过Passthru驱动与GPR(Generic Packet Router)协同工作,实现跨处理器的高效、异步数据交换,揭示了现代手机复杂音频系统背后的核心通信机制。 阅读详情

相关推荐

开发者的避坑指南:在Apple Silicon Mac上构建RocketMQ Python客户端的完整心路历程

本文详细记录了在Apple Silicon Mac上构建RocketMQ Python客户端的完整过程,重点解决了架构兼容性问题。通过源码编译rocketmq-client-cpp库,修复构建脚本和CMake配置,最终成功在M2芯片MacBook Pro上部署RocketMQ Python客户端,为开发者提供了实用的避坑指南。

Pepper的专栏 696

poj 4052 AC自动机

题意:给定2500个模式串,和长度为5,100,000的母串,问母串中包含多少个模式串。如果模式串s1是模式串s2的子串,而且s2被母串包含,则s1应被忽略。 思路:首先比较常规,对模式串建立AC自动机。然后用母串S在trie图上遍历,如果: 1、走到未被忽略的终止节点x,则将x标记为已经匹配,并且忽略掉所有目前匹配串的所有子串。  2、走到危险但非终止的节点y, 则沿着y的前缀指针链找到第

dearmango 765

基于OpenMV与双舵机云台的激光追踪系统实战解析

本文详细解析了基于OpenMV摄像头与双舵机云台的激光追踪系统设计与实现。从硬件选型、图像识别算法到PID控制逻辑,全面介绍了如何构建一个高效稳定的激光追踪系统,并分享了电子设计竞赛中的实战经验与调试技巧。该系统在智能玩具、安防监控及教学演示等领域具有广泛应用前景。

prometheus9mon的博客 261

AC自动机入门-poj3461解法

前提 : 1. KMP 单模式匹配原理 2. 字典树结构失配函数获取: 1. 找当前点s的失配节点下标为c, 先找到找父节点f的失配节点fail[f], 如果fail[f]存在下标为c子节点, 那么fail[s] = ch[fail[f]][id] 不存在沿着失配指针回推fail[….fail[f]]直至根节点 2. 由于是树形, 所以一般采取bfs递推fail值, 而

退役ACMer 418

WordPress主题开发实战:从零开始手把手教你创建自定义主题(含常用函数大全)

本文是一份WordPress主题开发实战指南,从零开始手把手教你创建自定义主题。内容涵盖主题核心文件结构、模板层级与循环机制、函数与钩子的运用,并附有详细的常用函数大全,帮助开发者彻底掌握主题开发的核心技能,实现从使用者到创造者的转变。

weixin_27943395的博客 256

别再只盯着GPS了!手把手教你用Python仿真UWB定位,30厘米精度是怎么算出来的?

本文详细解析了UWB(超宽带)室内定位技术的原理与实现,通过Python代码演示如何从三边测量法到实现30厘米精度的定位。文章涵盖了UWB的核心数学模型、Python仿真环境搭建、误差分析及优化策略,为开发者提供了实用的技术指南和应用场景。

weixin_26873711的博客 252

POJ 1204 【AC自动机】

开始wa掉了,360行的代码找错真难受!!!居然是一个地方多减了一个1…… #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #ifdef _WIN32 #define

量子流逝 692

GDI文字绘制和windows下opengl文字绘制小结

GDI绘制文字,要设置文字的属性,主要就是通过设置DC中的font对象来实现的。 font对象的创建可以由createfont()、createfontIndirect()来实现。 HFONT CreateFont( int nHeight, // height of font int nWidth, // average

T_W_S的专栏 5321

poj 4052 Hrinity 2012 金华邀请赛 AC自动机 DFA

/* 题意: 给定一些匹配串和一个模式串,问有多少个匹配串出现在模式串中。、 1.相同的匹配串记为一次 2.如果匹配串s1和s2都出现在模式串中,那么忽略s1 题解: 如果没有条件2,就是很经典的AC自动机题了。 按照经典方法我们可以找出所有出现过的匹配串,记为集合T,然后再这些串中去掉可以作为T中非自身子串的串 */ #include&lt;cstdio&gt; #include&lt;queu...

hududumo 198

基于Simulink环境,提供一个关于如何对EMI抑制的DC-DC变换器进行仿真建模的示例

EMI定义:电磁干扰是指任何能中断、阻碍、降低或限制电气设备有效性能的电磁能量。重要性合规性:确保产品符合国际和地方的EMC标准。可靠性:减少因外部或内部EMI导致的系统故障风险。挑战滤波设计:合理设计输入输出滤波器以抑制传导EMI。布局与接地:良好的PCB设计对于减少辐射EMI至关重要。屏蔽:使用金属屏蔽来保护敏感电路不受外界干扰。首先明确要模拟的任务内容。设计一个能够在高频操作下有效抑制EMI的DC-DC变换器。根据工作频率和谐振元件值确定合适的滤波器参数。

xiaoheshang_123的博客 145

PostgreSQL性能优化:如何搭建监控体系?

本文系统讲解如何构建企业级PostgreSQL监控体系,覆盖四大核心维度:基础设施层、数据库实例层、会话与查询层、对象与存储层。通过Prometheus+Grafana+ELK等工具链实现指标采集、可视化与告警闭环管理,详细解析关键监控指标、部署方法及告警策略设计,帮助DBA快速定位慢查询、连接泄漏、存储膨胀等典型故障,构建"看得见、管得住、防得早"的数据库运维能力。

数据知道的博客 2232

【POJ 4052】Hrinity(AC自动机)

【POJ 4052】Hrinity(AC自动机)题目是PDF版,地址在:http://poj.org/problem?id=4044题目大意:多模式串匹配,给出的是经过压缩的串,解压即可。 问文本串有几个模式串能跟他匹配。如果有多个互相包含的模式串,只记录最外层的。因为说解压前后总长度不超过5∗1055*10^5,所以全部建出个AC自动机。然后先用文本串匹配,把匹配到的标记。然后对于每个被标记的模

ACMer' 1651

基于FPGA的BP神经网络Verilog设计与Matlab仿真

BP(Backpropagation)神经网络是一种常见且广泛应用的神经网络类型,通过反向传播算法实现训练和学习。本文将介绍如何使用Verilog语言在FPGA上设计一个简易的BP神经网络,并使用Matlab进行仿真验证。BP神经网络由输入层、隐藏层和输出层组成。在上述Verilog代码中,我们定义了BP神经网络的输入层、隐藏层和输出层的神经元数量,并声明了相应的信号和参数。在上述Verilog代码中,我们定义了BP神经网络的输入层、隐藏层和输出层的神经元数量,并声明了相应的信号和参数。

2301_79326254的博客 559

poj 4052 Hrinity AC自动机

poj 4052AC自动机精简做法,109行搞定,代码量较平均减少30%。

sepNINE的专栏 1188

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

POJ 4052 Hrinity [AC自动机]

  跟2010福州的现场赛那题基本一样的,只是多了个去重。。上半年在金华邀请赛的时候还不会AC自动机,今天突然想起来就找出来写了一下。。数据给的很大,不过空间给的也是巨大=。=   解码后就是裸的自动机,把包含的串标记一下,再用自动机找这些串的子串去重即可。 1 #include <string.h> 2 #include <stdio.h> 3 #def...

weixin_33735077的博客 116

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

POJ 4052-Hrinity(KMP算法+AC自动机)

题目大意:给出一系列模式串,可能是以压缩形式给出的,并给出文本串,求问模式串总共出现了多少次,如果同一个模式串出现多次,只算一次,如果模式串A和B出现了,模式串B是A的子串,那么B不算。 首先对字符串解压,然后对解压之后的模式串存入AC自动机中,接着算出哪些匹配,对于那些匹配的,我是KMP算法判断是否有子串的关系。 #include #include #include #def

dilemma的专栏 515

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

POJ 4052 Hrinity AC自动机 *

题目地址:http://poj.org/problem?id=4052 思路: 对终止节点定义两种操作:全忽略和半忽略 若a是终止节点,则全忽略a表示: 1)若a的父节点为根,则全忽略就是忽略a 2) 其他情况,全忽略a即为: 忽略a,并且全忽略a的前缀指针链上的全部终止节点 对a到根的路径上的所有危险节点ki,沿着ki的前缀指针 链全忽略所有终止节点(若ki是终止节点,则全忽略k

BRCOCOLI的博客 699

POJ 4052 Hrinity(AC自动机)

每次优化的时候标记尽量不一样,那样可以分的清楚一点。// // main.cpp // Richard // // Created by 邵金杰 on 16/9/4. // Copyright © 2016年 邵金杰. All rights reserved. // #include #include #include #include #include using namespac

qq_33901573的博客 412

poj 4052(ac自动机)

题意:自己百度吧!! 分析:就是通过它的fail指针来找出它的子串就行了,这题其实不难的。这好像还是金华邀请赛的题哦! 代码实现: #include<cstdio> #include<cstring> #include<cstdlib> #include<iostream> #include<queue> using ...

weixin_30355437的博客 148

POJ 4052 Hrinity (金华邀请赛I题) AC自动机

题目大意: 就是给你 n 个压缩形式的字符串 n

Gatevin的专栏 1292

Poj 4052 Hrinity (金华邀请赛I)(字符串_AC自动机)

题目链接:http://poj.org/problem?id=4052 题目大意:北大还没把题目放出来,大意是给定n个字符串和一篇文章,求这些字符串中有几个在文章,如果某些字符串是某个字符串的字符串,那合起来只能算一个。最后输出含有的个数。 解题思路:这题在参加现场赛时根本就没看,不过当时也不一定做的出来,毕竟半年没做ac自动机了。这两天花了些时间把以前比赛未过

2672

poj4052 Hrinity

Hrinity 题目背景: POJ - 4052  分析:明明不算太难的题,我前前后后断断续续调了一个月······也不知道当时怎么想的,其实说白了就是三个步骤,一把所有的模式串建成自动机,二用匹配串跑一遍,标记所有的被匹配的串,然后针对所有匹配上的串清除其子串,之后统计一下答案即可。中间本人出问题的点已经在代码中进行了标注。 Source: #include #include

scarlyw的博客 375

AC自动机总结

前言 写了一下AC自动机的题目,发现蛮喜欢出AC自动机+dp的题目。而且dp状态通常为dp[i][j]dp[i][j]dp[i][j]表示已经串长iii,然后匹配到了自动机的jjj节点。这里写一下总结 P4052 [JSOI2007]文本生成器 题目链接:[JSOI2007]文本生成器 题目大意:给定nnn个单词,求出有多少个长mmm的文章包含至少一个单词。 数据范围:1≤n≤60,1≤m≤100,1≤∣si∣≤100。1≤n≤60,1 \leq m \le100 ,1≤|s_i|≤100。1≤n≤60,1

lin_rany的博客 490

【字符串_AC自动机专辑】【10.18更新】

一、总概述:     在acm用到的算法中我觉得字符串类算法在实际中的应用价值可能最大,因为我们很多时候在和字符串打交道,在和匹配、查询打交道,比如我们按Ctrl+F的查找,目测有用Kmp匹配算法,linux下的fgrep利用AC自动机实现,还有很多的哈希方法也在各种实际应用中展现它的价值等等。      本文针对AC自动机做个总结,并附带若干题解。       建立AC自动机的

3070

POJ 4052 金华邀请赛I题

写了个数组版的ac自动机,感觉还不错 #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #ifdef _WIN32 #define i64 __int64 #defi

量子流逝 1895

【字符串_AC自动机专辑】

一、总概述:     在acm用到的算法中我觉得字符串类算法在实际中的应用价值可能最大,因为我们很多时候在和字符串打交道,在和匹配、查询打交道,比如我们按Ctrl+F的查找,目测有用Kmp匹配算法,linux下的fgrep利用AC自动机实现,还有很多的哈希方法也在各种实际应用中展现它的价值等等。      本文针对AC自动机做个总结,并附带若干题解。       建立AC自动机的一般步骤是:

671coder的专栏 6918
上一篇: POJ-4047-线段树
下一篇: POJ-4045-数据结构+dfs
walk_up
博客等级 码龄15年 2粉丝 34原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值