poj 1625

CST新手必看:共面波导色散曲线绘制全流程(附参数设置详解) 本文为CST新手提供了绘制共面波导色散曲线的完整流程与参数设置详解。从模型搭建、周期性边界条件设置,到本征模求解器配置和参数扫描技巧,逐步解析关键步骤,并分享后处理与结果验证方法,帮助用户高效完成仿真任务。 阅读详情

poj 1625


题意:
现有一个奇葩的国家。总统不允许任何含有非法单词的句子出现。假定这个国家的句子长度固定为m。现给定大小为n 的字符集,和p个长度为min(m,10)的非法单词。任何包含非法单词的句子都是非法的。求所有合法句子的数目。
为了解决这个问题
我们先假定字符集{‘A’,’G’,’C’,’T’}
非法单词有2个,分别是”ACG”, “C”,句子长度为m
我们将非法串建立trie,得到如下的图


这张trie图和普通的trie树不同之处在于,它补全了所有trie树中原本不存在的边。每一个状态节点的某一个子节点若不存在,则将其指向这个状态节点的fail节点所对应的那个相同的子节点。即 若 ch[r][c]==0,ch[r][c]=ch[f[r]][c](大白书的写法) 这样一来原来的trie树变成了一张有向的状态转移图。从trie图中的根节点开始,沿着有向边走m步,即可得到一个长度为m的字串。
我们知道的是,自动机上的字串匹配其实就是各个状态间的转移,后缀与前缀之间的互相匹配的过程。不包含非法单词其实可以理解为,在走m步的过程中没有经过任何trie树上的单词结尾状态节点,也就是上面trie图中所标出的红色节点。因为无论trie图中的状态从何转移而来,其已经匹配过的字串必定包含从根节点到当前状态节点的路径所代表的非法单词。而包含非法单词的句子是不被允许的,因此在沿着有向边转移m次的过程中,不能转向任何非法单词结尾状态节点。同理,也不能从任何的非法节点转出。
现在问题变成了,从根节点开始转移m次至合法节点,共有多少种不同的方案。设计二维状态dp[i][j]表示第i步走到第j个节点的方案总数。
转移方程:dp[i][j] += dp[i-1][k](k到j有一条有向边且k,j均不为非法节点)
dp边界状态为:dp[0][0]=1; dp[0][k] = 0;(0<k<sz,sz为所有状态节点总数目)


需要注意的有两点:
1. 可能某一个非法单词包含了另一个非法单词。如上图中’ACG’和单词’C’,在这种情况下,2状态节点也需要被标记为非法的状态。因为匹配了’ACG’就一定匹配了’C’。在实际过程中只需要判下last[j]==root
2. 题中没有提到取模,因此要使用大数相加。


下面帖代码:

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#define maxnode 105
#define sigma_size 52
using namespace std;

const int base = 10;

int n, m, p;

int ch[maxnode][sigma_size];
int val[maxnode];
int sz;

int f[maxnode];
int last[maxnode];

char charset[maxnode];
char ban[12];

int get(char a)
{
    for(int i = 0; i < n; i++)
        if(charset[i] == a)
            return i;
    return -1;
}
void initial()
{
    memset(ch[0], 0, sizeof(ch[0]));
    sz = 1;
}
void insert(char *s)
{
    int l = strlen(s);
    int u = 0;
    for(int i = 0; i < l; i++)
    {
        int c = get(s[i]);
        if(!ch[u][c])
        {
            memset(ch[sz], 0, sizeof(ch[sz]));
            val[sz] = 0;
            ch[u][c] = sz++;
        }
        u = ch[u][c];
    }
    val[u] = 1;
}
void getfail()
{
    queue<int >q;
    f[0] = 0;
    for(int c = 0; c < n; c++)
    {
        int u = ch[0][c];
        if(u)
        {
            f[u] = 0;
            q.push(u);
            last[u] = 0;
        }
    }
    while(!q.empty())
    {
        int r = q.front();
        q.pop();
        for(int c = 0; c < n; c++)
        {
            int u = ch[r][c];
            if(!u)
            {
                ch[r][c] = ch[f[r]][c];
                continue;
            }
            q.push(u);
            int v = f[r];
            while(v && !ch[v][c])
                v = f[v];
            f[u] = ch[v][c];
            last[u] = val[f[u]] ? f[u] : last[f[u]];
            // if(last[u])
            //   val[u] = 1;
        }
    }
}
struct BigInt
{
    int v[maxnode], len;
    BigInt(int r = 0)
    {
        memset(v, 0, sizeof(v));
        for(len = 0; r > 0; r /= base)v[len++] = r % base;
    }
    BigInt operator + (const BigInt &a)
    {
        BigInt ans;
        int i , c = 0;
        for(i = 0; i < len || i < a.len || c > 0; i++)
        {
            if(i < len)c += v[i];
            if(i < a.len)c += a.v[i];
            ans.v[i] = c % base;
            c /= base;
        }
        ans.len = i;
        return ans;
    }
    void print()
    {
        printf("%d", len == 0 ? 0 : v[len - 1]);
        for(int i = len - 2; i >= 0; i--)
            printf("%d", v[i]);
        printf("\n");
    }
};
BigInt dp[52][maxnode];
int check(int k, int j)
{
    int ans = 0;
    for(int i = 0; i < n; i++)
        if(ch[k][i] == j)
            ans++;
    return ans;
}
int main()
{
    initial();
    scanf("%d%d%d", &n, &m, &p);
    scanf("%s", charset);
    while(p--)
    {
        scanf("%s", ban);
        insert(ban);
    }
    getfail();
    //初始化边界条件
    for(int i = 0; i <= m; i++)
        for(int j = 0; j < sz; j++)
        {
            dp[i][j] = BigInt();
        }
    dp[0][0] = BigInt(1);

    //dp过程
    for(int i = 1 ; i <= m; i++)
    {
        for(int j = 0; j < sz; j++)
        {
            if(val[j] || val[last[j]])
                continue;
            for(int k = 0; k < sz; k++)
            {
                if(val[last[k]] || val[k])
                    continue;
                int ti=check(k, j);
                for(int c=0;c<ti;c++)
                    dp[i][j] = dp[i][j] + dp[i - 1][k];
            }

        }
    }
    BigInt ans = BigInt();
    for(int i = 0; i < sz; i++)
    {
        ans = ans + dp[m][i];
    }
    ans.print();
    return 0;
}
成本150元的高性能RDP协议瘦客户机 云终端市场是一个跨度很大的市场。既有数千元的品牌的瘦客户机,也有几百元的瘦客户机,还有200-300元的支持RDP协议的多用户云终端。但是200-300元的多用户终端,在显示性能上不尽人意,一般用于地产中介门店,工厂产线的电子看板等场合。有没有性能更好,价格更低的方案呢? 答案是有。 这个方案就是 二手的x86 瘦客户机 + DoraOS瘦客户机系统免费版(仅支持RDP)。 首先我们看硬件,在某宝搜索 升腾C92 ,找到最低配置的( CPU:J1800,内存:2G,硬盘:8G)。价格都在150以内。 阅读详情

相关推荐

从原理到实践:MIPI D-PHY v1.2的HS-Deskew功能全解析(附时序图详解)

本文深入解析MIPI D-PHY v1.2的HS-Deskew功能,从技术背景到实现机制,详细介绍了其在2.5Gbps高速传输中的关键作用。通过时序图详解和实测数据,帮助工程师理解并应用这一技术,解决信号完整性问题,提升系统可靠性。

weixin_30300225的博客 313

POJ1625----AC自动机+大数+DP

题目地址:http://poj.org/problem?id=1625 题目意思: 给你一个字典,里面有n个不同的字符 然后给你p个不允许出现的字符串 要你求出在由字典里的字符组成的一个m长度的字符串不含禁止字符串的种数有多少 解题思路: 假设在一个AC自动机上,状态j的长度已经有i了,用dp[i][j]表示 那么dp[i+1][tmp] += dp[i][j]  其中tmp这个节点

Bob Lee's Blog For CS 856

蓝牙Mesh协议一基本概念

前言 蓝牙SIG联盟在2017年发布了蓝牙Mesh1.0的协议规格,基于低功耗广播包来实现的多对多的通信技术,Mesh协议建立在BLE的物理层和链路层上,所以也可以和BLE的蓝牙进行通信 本章主要介绍蓝牙Mesh的基本概念和协议中的层级结构,也是参考网上的资料,如有异议,欢迎留言指正 基本概念 广播和洪泛 蓝牙Mesh技术是基于BLE的广播报文来实现的,是一种洪泛的消息传输机制,Mesh网络的节点间通过3个广播信道进行通信。当蓝牙Mesh网络中的节点收到消息后会转发这条消息,大大增加了网络的覆盖范围;但

9754

poj-1625 Censored![ac自动机+dp+高精度]

题目地址 先把病毒串丢进ac自动机里面。 dp[i][j]表示长度为i的从trie图的根节点到j满足条件的串的数量。 因为答案很大,要用到高精度。 注意的是建图的时候,ed[u] |= ed[f[u]],如果失配指针的位置是病毒的话那么u也不能匹配。 #include<cstdio> #include<cstring> #include<algorithm> #...

qq_39921637的博客 292

【SAP中的框架协议】

在SAP中,框架协议(Framework Agreement) 是企业与供应商签订的长期采购约束文件,用于简化重复性采购流程、锁定交易条款并降低管理成本。

m0_73548864的博客 1300

Office如何通过VSTO进行WORD插件开发?

VSTO(Visual Studio Tools for Office )是VBA的替代,是一套用于创建自定义Office应用程序的Visual Studio工具包。VSTO可以用Visual Basic 或者Visual C#扩展Office应用程序(例如Word、Excel、PPT)。本文通过VSTO进行Word插件开发总结,并进行记录。

【cacrle】的博客 7328

POJ 1625 Censored!(自动机DP+高精度)

题意:给出包含n个字符的字符集,以下所提字符串均由该字符集中的字符构成。给出p个长度不超过10的字符串,求长为m且不包含上述p个字符串的字符串有多少个。 数据范围:1 思路:设不同的后缀为不同的状态,可以由自动机建立状态转移图DFA,确定状态转移矩阵即可 由于本题没对结果取模,所以是高精度,所以m的范围很小50,不需要矩阵二分幂,否则会更麻烦,所以最多连成50次矩阵,复杂度O(n^2*m

kalilili的专栏 740

① Django手把手从零开发个人博客-前言

手把手教你从零开始玩转手把手教你从零开始玩转Django,全面学习并了解django的运行机制、开发全流程及线上部署。Django,全面学习并了解django的运行机制、开发全流程及线上部署。 专栏介绍 本套教程遵循Django的设计思想,开门见山,快速切入主题,拒绝拖沓,在实战中学习每一个知识点,提高学习的趣味性以及个人成就感,并且能快速将所学运用到实际项目中。 将从零手把手带着你一步步完成博客的每一个功能,通过实现博客文章列表页、文章详情页、作者页面等功能来学习和了解django的视图查询模块相关知.

轻编程的博客 518

poj 1625 AC自动机上的DP_codestorm_新浪博客

转自:http://blog.csdn.net/ascii991/article/details/7462427 【题意】 给定N个字符集合和P个禁用的字符串,求长度为M的合法字符串个数。 【题解】 显然是AC自动机上的DP。 令dp[i][j]表示长度为i,状态为j的字符串个数。 按自动机的图转移即可,但要注意细节。 贡献几组数据。 50 ...

codestrom04 121

C# 调用高德地图关键词 API

今天我们要一起探索如何使用 C# 来调用高德地图的关键词搜索 API,从而实现精准的地理位置搜索功能。高德地图的关键词搜索 API 可以帮助我们轻松地实现这一点,它能够返回一系列匹配关键词的地点坐标和其他相关信息。通过简单的几行 C# 代码,我们就实现了调用高德地图关键词搜索 API 的功能。接下来,我们将在一个 C# 控制台应用中实现调用高德地图关键词搜索 API 的功能。此外,如果要在生产环境中使用,还需要考虑安全性问题,例如不要在客户端暴露 API 密钥。🔥关注墨瑾轩,带你探索编程的奥秘!

java专栏 1109

openlayers全面教程306+【目录】

vue+openlayers系列教程旨在为开发者提供简单快捷的示例。在每一个示例中,解释相应的API知识点。

大剑师兰特的GIS世界 2万+

poj 1625 AC自动机+动归+大数加法

题意:给出一个字符集V和P个模式串(长度小于10),问由这个字符集中字符组成的长度为N的且不包含任意一个模式串的字符串有多少个?(字符集大小,N 思路:先将P个模式串建立AC自动机,标记好危险节点(flag数组)。然后动归来求:dp[i][j]表示长度为i且最后在节点j的字符串个数(节点j必为安全节点),初始dp[0][1] = 1, 其他dp[i][j] = 0。由dp[i][j] 可以导出,

dearmango 437

【JCR一区级】鱼鹰算法OOA-CNN-LSTM-Attention故障诊断分类预测【含Matlab源码 5711期】

鱼鹰算法OOA-CNN-LSTM-Attention故障诊断分类预测 完整代码和数据,方可运行;数据可直接替换,适合小白!可提供运行操作视频!

订阅付费专栏Matlab(奶茶价版)或下载付费资源,可赠送奶茶价版付费专栏指定代码1份; 3607

POJ - 1625 Censored!

希望自己能成为日更博主 题目连接:http://poj.org/problem?id=1625 题目大意:给你n个字母,再给你p个字符串,问有多少个长度为m的只由给出的n个字母构成的字符串,且字符串不能包括给出的p个字符串; 题解:因为这个题不用取模,所以得使用高精度,参考了博客:https://www.cnblogs.com/shangyu/p/3730815.html;这个题和HD...

只能过样例嘤嘤嘤的博客 253

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

POJ1625 Censored! AC自动机+DP+高精度

 Problem Address:http://poj.org/problem?id=1625 【前言】这是我在POJ上的第100道题。前天做到了99,本来想随便找一道完成100的,结果没找着。昨天找了一道自动机+DP的。提交后返回WA。得知是高精度,才改写了加法运算。返回了AC,成功达到100。昨天CSDN说是什么七一维护,没法发解题报告。特此纪念第一百道题。 【思路】同上一篇一样的思路,构造出

Human_CK的专栏 1403

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

POJ 1625 Censored! AC自动机+DP+高精度 *

题目地址:http://poj.org/problem?id=1625 #include #include #include #include #include #include #include #include using namespace std; typedef long long LL; struct BigInteger{ int num[300]; int l

BRCOCOLI的博客 383

深度学习工具包 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")

POJ 1625 Censored!(AC自动机+DP)

POJ 1625 Censored!(AC自动机+DP) http://poj.org/problem?id=1625 题意:给你由特定N个字符组成的P个模板和长度M,问你由这特定N个字符组成的长为M的文本串不包含任意一个模板有多少种情况?M 分析:由于M http://blog.csdn.net/u013480600/article/details/23294375        我们

code 1456

POJ 1625 Censored!(AC自动机+高精度+DP(因为矩阵会T))

题目链接:http://poj.org/problem?id=1625 RE:爆char WA:还是爆char 解题思路: 思路和POJ2778是一样的:https://blog.csdn.net/weixin_43768644/article/details/99050540 但是这题矩阵快速幂会T 设字符种类为M,串长度为L,病毒串总节点数N 矩阵快速幂复杂度O(N^3*logL...

shadiao.的博客 152

poj1625 Censored! AC自动机DP、高精度

poj1625 Censored! AC自动机DP、高精度 这是AC自动机的经典题目了吧。 嗯,难度不大,就是代码长而已。。 poj的数据一如既往地奇葩,会有大于128的字符,读入变负,需要处理一下。 结果最大是50^50,大概是10^85,高精度的长度可以计算一下。 #include #include #include using namespace std; #def

Necs的小窝 689

poj1625-AC自动机-dp-大数

题目链接:http://poj.org/problem?id=1625 DescriptionThe alphabet of Freeland consists of exactly N letters. Each sentence of Freeland language (also known as Freish) consists of exactly M ...

测试 463

POJ 1625 Censored!(AC自动机+高精度+dp)

http://poj.org/problem?id=1625 题意: 给出一些单词,求长度为m的串不包含这些单词的个数。 思路: 这道题和HDU 2243和POJ 2778是一样的,不同的是这道题不取模,所以不可以用矩阵快速幂,必须使用高精度,所以这里用滚动dp解决即可。 高精度的写法参考了kuangbin巨巨的模板。 1 #include<iostream>...

weixin_30723433的博客 144

poj1625

题目大意:求不包含禁止串的长度为m的字符串个数。 题目思路:ac自动机,不过要用高精度,需要注意的是字符串有空格,而且要用无符号字符型,以前写的高精度用的是字符串模拟,这次见网上都用整型,且每一个整型数存多位十进制,而且效率很高,就果断学习了。 #include #include #include #include #include #include #include #inclu

xiaxiang123的专栏 469

Poj 1625 Censored! (字符串_AC自动机(DP))

题目链接:http://poj.org/problem?id=1625 题目大意:给定n个不同的字符,用这些字符组成长度为m的字符串但是不能出现p个危险字符串中的任何一个,危险字符串也不可以作为子串,问方案数有几种。 解题思路:这题可以用AC自动机+DP+高精度解。先不管那些危险字符串,本题可理解为n叉树,从根节点开始到叶子节点共有m层,方案数为n^m种,但是有

1357

poj 1625 Censored!

题目链接:http://poj.org/problem?id=1625 题目大意:求不包含禁止串的长度为m的字符串个数。 题目思路:ac自动机,不过要用高精度,需要注意的是字符串有空格,而且要用无符号字符型,以前写的高精度用的是字符串模拟,这次见网上都用整型,且每一个整型数存多位十进制,而且效率很高,就果断学习了。 #include&lt;stdio.h&gt; #include&lt;st...

java开发指南博客 【转载】 209

POJ 1625

AC自动机 + DP + 高精度 一开始开始犯蠢用矩阵相乘……好不容易搞定爆栈的问题又超时……后来发现还是直接dp的时间复杂度低…… 用 F[i][j] 表示 i 长的单词到 j 状态有多少种方法,则有 F[i][j] = sum{ F[i-1][k] } (k->j 可行 且j没有被标记) #include #include #include #include using nam

wxy__的专栏 1193

[POJ 1625] Censored! (AC自动机+DP+高精度)

链接POJ 1625题意给出P个模式串,问长度为M且不含有P中任何一个为子串的字符串有多少种。 给出了大小为N的一个字符集,属于ASCII但不一定为英文字母。 最终答案不进行取模,所以可能非常大。题解给出模式串找不含其中任何一个的串的种类数,这类的题目大多可以用trie图+矩阵快速幂解决。但是这道题目的答案不取模,显然要用高精度,如果用在矩阵快速幂中套用高精度。。。感觉即使不MLT也TLT了,所

mysterious 411
上一篇: zoj3865
下一篇: poj 2778
AndyTeen
博客等级 码龄12年 9粉丝 27原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值