POJ3691.DNA repair (Trie图 && DP)

POJ3691 DNA repair AC自动机+动态规划 Problem Address:http://poj.org/problem?id=3691 【前言】 关于这道题,我看了好几天。 刚开始确实很不好理解,不知道如何动态规划法。 不过慢慢地就看懂了。 看了很多解题报告,不过写的都不是很清楚。无奈最后终于又看了代码,才渐渐了解过来。 我觉得,很多题目都不是简单地考察一个知识点,而是多个知识点的结合。而我 阅读详情

给你若干个字符串,再给你一个字符串 T ,求最少修改 T 中的多少个字符,能使 T 不包含给出的若干个字符串。

首先是多串匹配问题,所以我们自然而然地想到了 AC 自动机。然后考虑 DP:f[ i ][ j ] 表示查找第 i 个字符时在自动机上的状态为 j 的答案, 然后枚举下一次转移的字符,如果下一次转移的字符和 T 下一位要匹配的一样且不是病毒串,那么答案不变,否则答案 + 1,当然仍不能是病毒串。为了 DP 方便转移,我们把 AC自动机的构建稍微修改一下,使之变成 Trie 图。注意:如果某节点为病毒串的结尾,那么这个节点的 fail 指针所指的节点也应标记。根据 fail 的性质可以知道,按这个指针转移过去的串也必定包含病毒串。

CODE:

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int MAX_N = 1005;
const int inf = 1000000000;

struct Trie {
	int ch[4], ed, fl;
} t[MAX_N];
int sz = 0, n, tot;
char s[MAX_N];

int get_num(char c)
{
	if (c == 'A') return 0;
	if (c == 'G') return 1;
	if (c == 'C') return 2;
	if (c == 'T') return 3;
}

void insert()
{
	int u = 0, l = strlen(s + 1);
	for (int i = 1; i <= l; i ++) {
		int c = get_num(s[i]);
		if (!t[u].ch[c]) t[u].ch[c] = ++ sz;
		u = t[u].ch[c];
	}
	t[u].ed = 1;
}

int q[MAX_N];

void get_Fail()
{
	int hd = 0, tl = 0;
    t[0].fl = 0;
    for (int c = 0; c < 4; c ++) 
        if (t[0].ch[c]) {
            t[0].fl = 0;
            q[++ tl] = t[0].ch[c];
        }
    while (hd < tl) {
    	int r = q[++ hd];
        for (int c = 0; c < 4; c ++) {
            if (!t[r].ch[c]) {
				t[r].ch[c] = t[t[r].fl].ch[c];
				continue;
			}
            q[++ tl] = t[r].ch[c];
            int u = t[r].ch[c], v = t[r].fl;
            while (v && !t[v].ch[c]) v = t[v].fl;
            t[u].fl = t[v].ch[c];
            if (t[t[u].fl].ed) t[u].ed = 1;
        }
    }
}

void init()
{
	for (int i = 1; i <= n; i ++)
		scanf("%s", s + 1),
		insert();	
}

char p[MAX_N];
int f[1005][1005];

void doit()
{
	get_Fail();
	scanf("%s", p + 1);
	int l = strlen(p + 1);
	memset(f, 0x7F, sizeof(f));
	f[1][0] = 0;  
    for (int i = 1; i <= l; i ++) {
        int w = get_num(p[i]);
        for (int j = 0; j <= sz; j ++)
        	if (f[i][j] <= 1000)
              	for (int k = 0; k < 4; k ++)
                 	if (!t[t[j].ch[k]].ed) {
                        int u = t[j].ch[k], x;  
                        if (k == w) x = f[i][j]; 
							else x = f[i][j] + 1;
                        if (f[i + 1][u] > x) f[i + 1][u] = x;                        
                 } 
    } 
    printf("Case %d: ", ++ tot);
	int ans = inf;
	for (int i = 0; i <= sz; i ++) 
		ans = min(ans, f[l + 1][i]);
	if (ans == inf) printf("-1\n");
		else printf("%d\n", ans);
}

int main()
{
	while (scanf("%d", &n) != EOF) {
		if (n == 0) break;
		sz = 0;
		memset(t, 0, sizeof(t));
		init();
		doit();
	}
	return 0;
}


视觉SLAM的前段后端最详细的梳理(硕士入门知识框架更新) 文章目录视觉SLAM的组成结构视觉里程计(VO)-特征点法 -构建稀疏点云地图-直接法 -构建稠密或半稠密的地图 --需要使用 RGB-D 传感器视觉里程计--总结:SLAM 后端研究滤波器法非线性优化后端方式的差异(有五种优化方式):单目视觉里程计的初始化:运动估计:半直接法运动估计的优化方案:关于解决累计误差的一些方法:关键帧的建图及后端优化:特征的深度估计:图优化的后端研究:视觉与IMU融合的分类:视觉与IMU的融合的优势:存在的问题:优秀的开源: 视觉SLAM的组成结构 视觉里程计(VO) -特 阅读详情

相关推荐

GPU八卡A100使用INT4-W4A16量化大模型实验

本实验旨在探索在环境下,对大语言模型进行权重量化的可行性、效率与性能影响。通过采用工具集成 GPTQ 算法,实现对所有线性层的权重量化(W4A16 方案最终通过lm-eval工具在GSM8K任务上对压缩模型进行评估。

goodgood_UP的博客 1909

POJ3691 第一道AC自动机+DP 指针版+总结

学了编译原理的自动机后理解起来容易多了,对于一个字符串我只关心最后几个字符组成的前缀是AC自动机中的哪个状态节点,然后在AC自动机上进行转移。 我们可以先构造一个AC自动机,然后把各个节点之间的合法联系做成矩阵,这样就方便后面查询了。 需要注意的地方: 1、判断一个节点是否合法,除了看自身外还要看其父节点和其fail指向的第一个节点。(考虑到子串包含的原因) 2、打合法关系表时,打出合法关

Matrix 882

BEVFormer vs BEVFusion:5个关键差异点帮你选对环视感知方案

本文深入对比了自动驾驶领域两大主流环视感知方案BEVFormer与BEVFusion。BEVFormer作为纯视觉BEV感知的标杆,通过注意力机制隐式学习深度,成本较低;而BEVFusion作为多模态融合典范,融合激光雷达与摄像头数据,在性能、小目标检测及极端环境鲁棒性上优势显著。文章从计算效率、部署成本、数据依赖性等五个核心维度提供选型指南,帮助技术决策者根据自身算力预算与传感器配置做出明智选择。

weixin_29306011的博客 124

POJ 3691 DNA repair AC自动机 + dp

传送门:POJ3691 题意:给定一个原字符串S和n个禁止模式串p1,p2...pn,请修改字符串S,使得其中不包含任何禁止模式串,只能将S中的字符修改为其他字符而不能增加或删除,如果怎么修改都不行,输出-1,否则输出最少修改次数。 思路:挑战程序设计P370例题,但是白书上不是用ac自动机做的,而是暴力预处理,我看网上dalao都是ac自动机或者说Trie图预处理,就学着写了一发,这也是第一

WA是一笔财富 437

从零做出可发布的2D冒险游戏!Unity全流程实战指南:从资源搭建到打包发布,新手也能跟着做

项目配置→资源导入→核心模块开发→关卡设计→调试→打包发布;玩家控制→敌人AI→道具系统→UI系统→游戏管理器→音效系统;新手开发重点:先实现核心玩法(移动、跳跃、攻击),再补充UI、音效、存档等辅助功能;调试是关键:每实现一个功能就测试,避免最后一堆bug难以定位。从零做一款完整的2D冒险游戏,能快速提升你的Unity综合能力——不仅能掌握C#编程、2D物理、UI系统,还能理解游戏开发的完整流程。先做出基础版,再慢慢迭代优化,你会发现游戏开发并没有想象中那么难。

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 1179

RPN 解析

RPN全称是Region Proposal Network,Region Proposal的中文意思是“区域选取”,也就是“提取候选框”的意思,所以RPN就是用来提取候选框的网络; 1. RPN的意义 RPN第一次出现在世人眼中是在Faster RCNN这个结构中,专门用来提取候选框,在RCNN和Fast RCNN等物体检测架构中,用来提取候选框的方法通常是Selective Se

lanran2的博客 10万+

poj 3691 AC自动机+dp(修复DNA使其不带病毒)

题意:给定不超过50个由 ‘A’, ‘G’ , ‘C‘ ,’T’。 四个字母组成的模式串,每个模式串长度不超过 20,再给一个不超过1000个字符长的同样由上述字母组成的母串S, 问在S中至少要修改多 少个字符,才能使其不包含任何模式串。 思路:对模式串建立AC自动机。然后在其上进行动态规划。Ans[i][j]表示若要用长度为i的母串的前缀遍历DFA树, 使之达到节点 j ,至少要修改的字符数量

dearmango 599

《科研伦理与学术规范》期末考试答案2023

26单选(2 分)某学术杂志的评稿人同时是某高校相关专业的硕士生导师,在评判一个稿件的时候,他发现该作者研究的题目很有价值, 他便一边压下这个稿子,一边将稿子的纲要传给自己门下的硕士生, 指导他们使用这个题目独立写出一篇论文,并帮助他们发表在其他期 刊上。D.要善待实验动物,是指在饲养管理和使用实验动物过程中,要采取有效措施,使实验动物免遭不必要的伤害、饥渴、不适、惊恐、折磨、疾病和疼痛,保证动物能够实现自然行为,受到良好的管理与照料,为其提供清洁、舒适的生活环境。张某在压力之下不得不屈从。

Glenseeds的博客 4万+

poj 3691(AC自动机,新模板)

.题意是说给了N个带病毒的DNA串( DNA串只有AGCT几种单元组成)...再给一长串DNA..问这长串DNA最少改动几个(就是改..不是删除或者添加..)能保证没有包含病毒字串..输出这个最小改动的次数..若怎么修改都带病毒子串...输出-1... 思路:这是我第一道调bug调得快要发狂的代码,AC这道题花了我将近五个小时,md。其实思想很简单,就是将那些病毒DNA建成一棵AC自动机树,然后...

qq_39861441的博客 572

自动驾驶预测决策规划八股

预测规划八股个人总结。

dawushixiange的博客 479

从零搭建UVM验证环境:新手入门实践指南

在数字芯片验证领域,SystemVerilog和UVM(Universal Verification Methodology)是构建高效验证环境的核心技术。其原理基于面向对象编程和事务级建模,通过组件化架构实现验证的复用性和自动化。这一方法学的技术价值在于显著提升验证效率与质量,广泛应用于处理器、通信芯片等复杂设计的验证场景。本文聚焦于UVM验证环境的搭建实践,通过一个加法器实例,详细解析了uvm_driver、uvm_monitor、uvm_sequence等关键组件的协同工作机制,并提供了基于Quest

weixin_30015371的博客 446

POJ - 3691 DNA repair (AC自动机+DP)

题意:(换了一种描述,其实是一样的题) 分析: 首先对与这种题的题问,可以很明显地感觉到DP 因为很多模式串,所以考虑多模式匹配的AC自动机算法。 首先考虑建立fail树,跟正常的ac自动机的fail树其实是一样的,只不过多了一个东西,就是对于这种情况: 以下面这两个字符串建立fail树为例: CD ABCDAB 那么很显然第二个字符串中间的CD也是非法状态。所以对于建...

兜率工的博客 613

YOLO26 多模态融合技术:RGB+红外/深度/雷达融合

YOLO(You Only Look Once)是一种流行的目标检测算法,其最大特点是快速且端到端地完成图像中所有目标的检测与分类任务。YOLO首次在2016年由Joseph Redmon等人提出,彻底改变了传统目标检测(如R-CNN系列)的思路,被广泛应用于自动驾驶、视频监控、工业质检等场景。

一键难忘的博客 3523

POJ 3691 DNA repair ( Trie图 && DP )

题意 : 给出 n 个病毒串,最后再给出一个主串,问你最少改变主串中的多少个单词才能使得主串中不包含任何一个病毒串 分析 : 做多了AC自动机的题,就会发现这些题有些都是很套路的题目。在构建 Trie 图的时候给病毒串末尾打上标记,最后定义DP[i][j] = 长度为 i 的串在 j 这个状态节点最少改变数使得其不包含病毒串,则状态转移方程 if(Trie[k]不是被标记的病...

199

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

深度学习工具包 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 3691 DNA repair AC自动机+DP -

题目地址:http://poj.org/problem?id=3691 思路: 把所有节点建一棵trie树 那么我们要做的 就是把母串在树上搜索,而且在搜索的时候不会碰到危险节点 也即是对于节点j有条字母边a到son[j] , 1)如果son[j]是危险节点,那么换一条j的边 2)如果son[j]为空,就顺着前驱节点找另一个字母边a 3)如果以上都不是,那么比较a和插入母串的字符,如

BRCOCOLI的博客 350

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

POJ 3691:DNA repair(AC自动机+DP)

DNA repair Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 3353   Accepted: 1487 Description

WU.GJ 3102

老版QQ原生表情gif动态

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

【poj3691-DNA repair】AC自动机+DP

【poj3691-DNA repair】AC自动机+DP 题意:给n个病毒DNA序列,再给一个DNA序列,问该序列至少修改多少个碱基能不含任何病毒DNA。病毒DNA序列一共不超过1000,询问的DNA长度不超过1000。 题解:DP:d[l][p]表示询问到第l位、当前在AC自动机上的位置为p时的最少修改数,用d[l][p]推d[l+1][x]。...

qq_25768269的博客 129

【HDU 2457】 【POJ 3691】 DNA repair AC自动机+DP;

DNA repair Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1939 Accepted Submission(s): 1049Problem Description Biologists finally invent

ATOD 921

DNA repair POJ - 3691 自动机+dp

一、内容 Biologists finally invent techniques of repairing DNA that contains segments causing kinds of inherited diseases. For the sake of simplicity, a DNA is represented as a string containing character...

Tizzi的博客 659

DNA repair POJ - 3691(AC自动机 + DP)

Biologists finally invent techniques of repairing DNA that contains segments causing kinds of inherited diseases. For the sake of simplicity, a DNA is represented as a string containing characters 'A...

Top_Spirit的博客 307

poj 3691 DNA repair AC自动机+DP

Description Biologists finally invent techniques of repairing DNA that contains segments causing kinds of inherited diseases. For the sake of simplicity, a DNA is represented as a string cont

lastone的专栏 386

poj 3691 DNA repair(自动机+DP)

DNA repair Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 5142   Accepted: 2404 Description Biologists finally invent techniques of repairing DNA that c

街角的花街糖 722

POJ3691 DNA repair(AC自动机 DP)

给定N个长度不超过20的模式串,再给定一个长度为M的目标串S,求在目标串S上最少改变多少字符,可以使得它不包含任何的模式串 建立Trie图,求得每个节点是否是不可被包含的串,然后进行DP dp[i][j]表示在Trie图上行走i步到达节点j的要修改的最小次数,则 dp[i + 1][chi[j][k]] = min(dp[i + 1][chi[j][k]], dp[i][j]...

Nobel7889的专栏 157

poj 3691 DNA repair

记忆化搜索+AC自动机 我这题犯的最大的错误就是 写记忆化搜索的时候,进去之后就将dp值赋为0,这样如果后面没有可行方案的话dp值还是0。 多组测试样例的模板 #include <map> #include <queue> #include <cstring> #include <cstdio> using namespace std; co...

ehdhg13455的博客 200

hdu2457 & poj3691 DNA repair AC自动机+DP

乱搞了一下竟然1A了...太感动了....先给n个病毒DNA序列,再给一个长串。问最少修改长串几个字符,可以让它不包含任何一个病毒序列。拿病毒的序列构造AC自动机,之后再自动机上搞DP,用dp[l][i]表示当前长度为l,自动机上的状态为i时,最少的字符修改数.循环A,T,G,C四种方案,在添加该字符之后的状态为安全的前提下,如果当前方案和母串的第l为刚好相同,那么直接用dp[l][i]去更新dp

Broken Wings 984

POJ 3691 DNA repair (DP+AC自动机)

DNA repair Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4815   Accepted: 2237 Description Biologists finally invent techniques of repairing DNA that conta...

weixin_33768481的博客 168
上一篇: SPOJ3273.ORDERSET(Treap 模版)
下一篇: poj2778.DNA Sequence (Trie图 && 矩阵乘)
ALXPCUN
博客等级 码龄11年 4粉丝 61原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值