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;
代码:
SAP BTP ABAP environment 集成本地系统实践:Cloud Connector、Connectivity service 与隧道通信全解析 摘要: 随着ABAP开发者向云端扩展业务逻辑,如何安全访问企业内网SAP系统成为关键问题。本文基于SAP官方文档,解析通过Cloud Connector和Connectivity service实现云端ABAP环境与本地系统集成的方案。 架构上分为四个角色:ABAP环境、Connectivity服务、Cloud Connector和内网系统。Cloud Connector作为内网出口,通过TLS隧道主动连接云端,避免防火墙开放入站端口。Connectivity服务则作为子账户级“总机”,自动路由请求。 实施 阅读详情

相关推荐

ffmpeg 4.4 cenc-aes-ctr 加解密 MP4 工程性质分析

ffmpeg 4.4 cenc-aes-ctr 加解密 MP4 工程性质分析

Dream_Dynasty的博客 3045

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

R语言绘图进阶:五大工具高效组合多图(cowplot、patchwork、layout、par、gridExtra)

本文详细介绍了R语言中五大高效组合多图的工具:cowplot、patchwork、layout、par和gridExtra。针对不同场景提供了实用指南,帮助数据分析师解决图表排版难题,提升报告专业度。特别推荐cowplot用于ggplot2图形组合,patchwork提供最简洁语法,layout则支持完全自定义布局。

weixin_42544663的博客 288

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的专栏 1004

GPS从入门到放弃(一) --- GPS基础原理

GPS从入门到放弃(一) — GPS基础原理 GPS,全称Global Positioning System,已经广泛应用于我们的日常生活中了,现在的智能手机 里都会自带GPS定位功能。这是一个美国的全球定位系统,虽然我们现在也有北斗了,但毕竟GPS搞的早,所以先从它开始研究起。 整个GPS系统分三大部分: 地面站 卫星 接收机 地面站负责监控。它们通过接收、测量各个卫星信号,计算卫星的运行轨...

tyst08的专栏 2万+

平衡小车动力学建模

两轮自平衡小车由车体和双轮两部分组成,可以看成一个移动的倒立摆,分别对车轮和车体进行力学分析,建立动力学模型,最后,通过对两者的分析给出系统的状态空间表达式。[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-kjiPEUVJ-1679470559950)(C:\Users\DELL\AppData\Roaming\Typora\typora-user-images\image-20230322110521545.png)]

qq_23096319的博客 9053

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

记一次在JAVA中客户端使用axis调用webservice服务端出现的异常:Unmarshalling Error: For input string: ""

在使axis调用webservice服务端,参照网上给的demo: Call call = (Call) service.createCall(); call.setTargetEndpointAddress(endpoint);//设置服务请求路径 QName qn = new QName(name); call.setOperationName(qn); call.addParamet

kry1201的专栏 8080

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

深度学习-161-Dify工具之对比使用工作流和聊天流生成图表可视化的html文件

分别使用聊天流和工作流进行数据分析结果的可视化,生成html文件。聊天流可以配置带记忆,这样就可以多次交互优化结果。

qq_20466211的博客 1709

STM实战开发(13):STM32开发:使用光敏电阻检测光照强度

光敏电阻(LDR)是一种电阻值受光照强度影响的半导体材料。当光照强度增大时,光敏电阻的电阻值降低;而当光照强度减小时,电阻值则增大。光敏电阻的电阻变化与入射光的强度之间并不是线性关系,而是呈对数型的变化。LDR通常由硫化镉(CdS)或其他半导体材料构成,材料对不同波长的光有不同的响应特性。一般而言,光照强度越强,光敏电阻的电阻值越低,反之则越高。本文介绍了如何使用STM32与光敏电阻(LDR)结合,进行光照强度检测的实现方法。通过配置STM32的ADC模块,读取光敏电阻的电压信号,并根据电压计算光照强度。

2201_76125393的博客 3017

POJ 3356 AGTC

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

Happye0101的博客 264

YOLO26涨点改进 | 全网独家复现、小目标检测改进篇 | TGRS 2025 | YOLO26引入MFAE-YOLO中的GFFP、FCPS 和 C3k2-FPEU创新点,涨点起飞,直接发论文

🔥本文给大家介绍在YOLO26中引入MFAE-YOLO中的 GFFP(全局特征融合处理)、FCPS(特征通道像素注意力) 和 C3k2-FPEU(特征池提取单元) 二次创新改进模块,能显著提升对小目标的检测性能。GFFP通过多尺度特征融合增强全局上下文感知能力,有效提升小目标在复杂背景下的可辨性;FCPS融合通道、像素和空间注意力机制,增强了模型对关键细节和小区域特征的关注,提升检测精度;C2F-FPEU利用多种池化方式挖掘细节特征,优化浅层特征表示能力。三者协同提升了YOLO26在小目标检测中的鲁棒性。

Ai缝合怪、助力小伙伴高效发论文 305

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

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

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

假人有限元模型

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

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的博客 676

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

(简单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 742

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 博客 1069

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的专栏 442

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
博客等级 码龄18年 176粉丝 135原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值