POJ3356AGTC题解动态规划DP

pku acm 3356 AGTC Java代码 pku acm 第3356题 AGTC Java代码,有详细的注释,动态规划 立即下载
AGTC
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 4870 Accepted: 1879

Description

Let x and y be two strings over some finite alphabet A. We would like to transform x into y allowing only operations given below:

 

  • Deletion: a letter in x is missing in y at a corresponding position.
  • Insertion: a letter in y is missing in x at a corresponding position.
  • Change: letters at corresponding positions are distinct

 

Certainly, we would like to minimize the number of all possible operations.

Illustration

 

A G T A A G T * A G G C

| | | | | | |
A G T * C * T G A C G C

 

Deletion: * in the bottom line
Insertion: * in the top line
Change: when the letters at the top and bottom are distinct

This tells us that to transform x = AGTCTGACGC into y = AGTAAGTAGGC we would be required to perform 5 operations (2 changes, 2 deletions and 1 insertion). If we want to minimize the number operations, we should do it like

 

A  G  T  A  A  G  T  A  G  G  C

| | | | | | |
A G T C T G * A C G C

 

and 4 moves would be required (3 changes and 1 deletion).

In this problem we would always consider strings x and y to be fixed, such that the number of letters in x is m and the number of letters in y is n where n ≥ m.

Assign 1 as the cost of an operation performed. Otherwise, assign 0 if there is no operation performed.

Write a program that would minimize the number of possible operations to transform any string x into a string y.

Input

The input consists of the strings x and y prefixed by their respective lengths, which are within 1000.

Output

An integer representing the minimum number of possible operations to transform any string x into a string y.

Sample Input

10 AGTCTGACGC
11 AGTAAGTAGGC

Sample Output

4

Source

状态:
d[i][j]表示a串前i个字符和b串前j个字符的最小编辑距离
状态转移方程:
d[i][j]=min(d[i-1][j-1]+(a[i]!=b[j]),d[i-1][j]+1,d[i][j-1]+1)
边界:
d[i][0]=i;
d[0][j]=j;
代码:
【模拟电子设计实战】开源!基于Multisim与AD620的心电采集电路仿真与优化 本文详细介绍了基于Multisim与AD620的心电采集电路仿真与优化实战。通过分析心电信号采集的挑战,重点讲解了AD620仪表放大器和OP07运算放大器的选型优势及电路设计技巧,包括对抗50Hz工频干扰和基线漂移的优化方法。文章还分享了Multisim仿真参数设置与实测对比经验,最终实现性能达标的心电采集电路设计。 阅读详情

相关推荐

分享通达信破解交易接口的使用!

那其实通达信破解交易接口的使用方法比较复杂,这里以MA均线指标为例子,只要理解了这些操作步骤,就可以很容易地使用其他指标包括自己编写的指标来进行交易。委托结果(包含委托编号), 需要分配 1024*1024 字节的空间。委托结果数组, 每项结果需要分配 1024*1024 字节的空间。0: 买入, 1: 卖出, 2: 融资买入, 3: 融券卖出,4: (市价委托)上海五档即成剩撤, 深圳五档即成剩撤。4: 买券还券, 5: 卖券还款, 6: 现券还券。0: 上海限价委托, 深圳限价委托。

1841085904的博客 2370

poj 3356 编辑距离(空间优化)

AGTC Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7780   Accepted: 3087 Description Let x and y be two strings over some finite alphabet A. We would lik

keynumber的专栏 1422

大麦网抢票软件工具开发系列(一)

前言《大麦网》都知道吧,就是那个被网友声称“大麦网你卖啥了?”票务平台。近期有听到朋友说《大麦网》的票很难抢,基本上都是说:“哎哟喂,被挤爆啦,请稍后重试!”,也不知道《大麦网》...

架构文摘 1万+

pku 3356 AGTC

AGTC Time Limit:1000MS  Memory Limit:65536KTotal Submit:1285 Accepted:395Description Input Output Sample Input Sample Output4#include iostream>#include string>using namespace std

liyanguestc的专栏 1005

车牌识别系统

随这图形图像技术的发展,现在的车牌识别技术准确率越来越高,识别速度越来越快。无论何种形式的车牌识别系统,它们都是由触发、图像采集、图像识别模块、辅助光源和通信模块组成的。车牌识别系统涉及光学、电器、电子控制、数字图像处理、计算视觉、人工智能等多项技术。触发模块负责在车辆到达合适位置时,给出触发信号,控制抓拍。辅助光源提供辅助照明,保证系统在不同的光照条件下都能拍摄到高质量的图像。图像预处理程序对抓拍的图像进行处理,去除噪声,并进行参数调整。然后通过车牌定位、字符识别,最后将识别结果输出。 牌照自动识别是一

FPGA/MATLAB学习教程/源码/项目合作开发 2万+

2.STM32F407ZGT6 学习笔记-移植 FreeRTOS

1. 在工程下建议FreeRTOS文件夹 2. 在FreeRTOS文件夹下建立 src 和 port 文件夹 (src用于存放freertos源码,port文件夹存放内存和接口相关的文件) 3. 复制freertos/source文件夹下所有c文件复制到刚刚建立的freertos/src目录下 4. 复制FreeRTOSv9.0.0\FreeRTOS\Source\portablex下的MemMang和RVDS文件夹复制到刚刚建立的port问价夹下 5. 将FreeRTOSv9.0.0\FreeRTOS

Car12 1236

POJ 3356 AGTC(最长公共子序列)

AGTC Description Letxandybe two strings over some finite alphabetA. We would like to transformxintoyallowing only operations given below: Deletion:a letter inxis missing...

weixin_30621919的博客 221

QGis二次开发 —— 1、win10/win11搭建Vs2017-QGis3.40.12环境(附Vs2017环境效果,附全部问题解决方法)(附:Qt助手加入QGis接口说明文档)

QGis二次开发 —— 1、Windows10搭建Vs2017-QGis环境(附Vs2017环境效果)(附:Qt助手加入QGisA接口说明文档)

1362

poj 3356

Description Let x and y be two strings over some finite alphabet A. We would like to transform x into y allowing only operations given below: Deletion: a letter in x is missing in y...

weixin_34273479的博客 156

大模型——Ollama简明教程

在这篇文章中,我们将了解如何使用 Ollama、如何在 Ollama 中创建自己的模型 以及如何使用 Ollama 构建聊天机器人。这是深入研究 Ollama 的第一部分,以及我所学到的有关本地 LLM 的知识以及如何将它们用于基于推理的应用程序。在这篇文章中,你将了解——

1724

POJ 3356 AGTC

POJ 3356 AGTC(最小编辑距离) 前辈原博客:https://blog.csdn.net/u013480600/article/details/40780781 http://poj.org/problem?id=3356 题意: 给出两个字符串x 与 y,其中x的长度为n,y的长度为m,并且m>=n.然后y可以经过删除一个字母,添加一个字母,转换一个字母,三种操作得到x.问...

Happye0101的博客 266

pcie硬件时序分析实战(PHY层眼图测量)​

PCIe高速接口的信号完整性(SI)直接影响系统带宽和稳定性。其中,​。

xiaoheshang_123的博客 862

AGTC POJ - 3356(字符串DP)

Let x and y be two strings over some finite alphabet A. We would like to transform x into y allowing only operations given below: Deletion: a letter in x is missing in y at a corresponding position. I...

tomjobs的博客 889

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

POJ 3356 AGTC(最小编辑距离)

POJ 3356 AGTC(最小编辑距离) http://poj.org/problem?id=3356 题意: 给出两个字符串x 与 y,其中x的长度为n,y的长度为m,并且m>=n.然后y可以经过删除一个字母,添加一个字母,转换一个字母,三种操作得到x.问最少可以经过多少次操作 分析: 我们令dp[i][j]==x表示源串的前i个字符变成目串的前j个字符需要x步操作. 初始化: dp[0][i]==i且 dp[i][0]=i. 上述前者表示添加源串

code 1843

visio安装包

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

AGTC POJ - 3356

一、内容 Let x and y be two strings over some finite alphabet A. We would like to transform x into y allowing only operations given below: Deletion: a letter in x is missing in y at a corresponding p...

Tizzi的博客 678

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

(简单dp) poj 3356 AGTC

AGTCTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 5058 Accepted: 1953<br />Description<br />Let x and y be two strings over some finite alphabet A. We would like to transform x into y allowing only operations given below:<br /> Deletion: a lett

Hashmat的专栏 959

poj 3356 AGTC(dp,最小编辑距离)

poj 3356 AGTC D(0, 0) = 0 D(i, 0) = insertCost * i D(0, j) = deleteCost * j D(i-1, j) + insertCost( targeti) D(i, j) = min D(i-1, j-1) + substituteCost( sourcej, targeti)  D(i, j-1) + dele

yjCola 743

DP(最短编辑距离)-AGTC POJ - 3356

DP(最短编辑距离)-AGTC POJ - 3356 题意: 给定两个长度分别为n和m的字符串a和b,允许进行3种操作:删除、插入,修改。求最少操作步骤,使得a与b相同。给定两个长度分别为n和m的字符串a和b,允许进行3种操作:删除、插入,修改。\\求最少操作步骤,使得a与b相同。给定两个长度分别为n和m的字符串a和b,允许进行3种操作:删除、插入,修改。求最少操作步骤,使得a与b相同。 Samp...

njuptACMcxk的博客 265

poj3356 AGTC dp把一个字符串经过最少步数转为另一个字符串

AGTC Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7371   Accepted: 2931 Description Let x and y be two strings over some finite alphabet A. We would like

Shirley 4199

poj 3356 AGTC(线性dp)

题目链接:http://poj.org/problem?id=3356 思路分析:题目为经典的编辑距离问题,其实质为动态规划问题; 编辑距离问题定义:给定一个字符串source,可以对其进行复制,替换,删除,增加操作,另外根据具体情况已经规定了每种操作的cost,现在要求求出一个操作序列,使其变为一个给定的字符串dest,并且该操作序列的cost的和最小(在该题目中复制开销为0,其他...

aqjh9999的博客 132

POJ 3356 AGTC 解题报告(Edit Distance,DP)

AGTC Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9579   Accepted: 3659 Description Let x and y be two strings over some finite alphabet A. We would lik

SF-_- 的 ACM 博客 1071

poj3356 AGTC 解题心得

原题: Description Letxandybe two strings over some finite alphabetA. We would like to transformxintoyallowing only operations given below: Deletion:a letter inxis missing ...

advyne9986的博客 170

POJ3356- AGTC(dp)

Description: Let x and y be two strings over some finite alphabet A. We would like to transform x into y allowing only operations given below: Deletion: a letter in x is missing in y at a correspondi...

weixin_43880485的博客 349

poj 3356 AGTC

/* Name: poj 3356 AGTC Author: UnimenSun Date: 17/05/2011 16:25 Description: LCS变形*//*解题报告:LCS的变形要求结果 = 串2的长度 - 两串的LCS*/#include #include #include #include using namesp

Unimen的专栏 446

poj3356 AGTC(经典DP最小编辑距离)

题目意思: 给出两个字符串X,Y,求出从X——>Y的最小操作次数,只可以删除,添加,修改一个字符。 http://poj.org/problem?id=3356 题目分析: /** *x,y:是字符串 *动态规划最小编辑距离, *dp[i][j]表示取x的前i个字符和y的前j个字符操作的最小次数。 *dp[0][j]=j:取x的前0个字符和y的前j个字符操作的 *最小

机器笨猫 1180
上一篇: 多重背包中多次背包 O(VN) 算法1 (单调队列优化) 带参考程序
下一篇: [SCOI2009]windy数 题解动态规划DP
power721
博客等级 码龄19年 176粉丝 135原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值