(简单dp) poj 3356 AGTC

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

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
 
谈谈SAP顾问的几个发展趋势 大家新年好,今天想聊一下对SAP顾问发展趋势的一些个人见解。过去10多年得益于我国的经济发展,外资不断加大在中国的投资和中国企业的发展,SAP顾问行业得到了很大的发展和壮大。那么未来几年SAP顾问的职业发展到底怎么样呢? 阅读详情

相关推荐

FunASR与FreeSWITCH融合实战:从零构建高精度语音质检系统

本文详细介绍了如何将FunASR与FreeSWITCH融合,构建高精度语音质检系统。通过实时语音听写技术,结合热词定制和多模型切换,实现客服中心等场景的自动化质检,显著提升识别准确率和效率。系统架构涵盖音频采集、识别处理和业务应用三层,支持负载均衡和性能优化,适用于工业级部署。

weixin_29198045的博客 980

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

OpenCV学习笔记(25)基于MFC和OpenCV的摄像机定标与立体匹配测试程序(20140505更新)

最近整理了一下这两年一直在用的摄像机定标与立体匹配测试程序,将代码进行了重构,界面也做了调整,分享出来方便有需要的朋友使用。当然我的编程能力有限,程序可能还有各种bug,请大家多多包涵。相关问题欢迎留言或email联系讨论,谢谢! ==================================================================================源码

晨宇思远 5万+

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

OpenCode:终端开源AI编程助手,多模型接入与实战指南

AI编程助手正在从IDE侧边栏走向终端环境。其核心原理是让模型直接读取项目文件、执行命令、查看报错,形成从诊断到修复的完整闭环,从而解决传统插件上下文割裂的问题。技术价值在于开源透明、模型无关,既可接入OpenAI等云端服务,也能通过Ollama连接本地模型,兼顾数据安全与离线场景。在工程实践中,它适用于长时间驻留项目、自动修Bug、团队统一AI工具链等需求。OpenCode正是这样一款终端AI助手,支持灵活配置第三方API密钥,提供免费档与Go套餐,并通过Skills技能系统让模型遵循标准操作流程。同时,

weixin_28745821的博客 326

基于Simulink的间接功率控制的矩阵变换器

通过上述步骤,我们成功设计并实现了基于 Simulink 的间接功率控制的矩阵变换器仿真模型。该模型能够通过控制输入电流和输出电压,实现对功率的间接控制,适用于电机驱动、可再生能源系统、电力传输等领域。通过虚拟场景仿真、参数优化和性能评估,验证了系统的稳定性和高效性,并通过调整 PI 控制器参数和优化调制算法,进一步提升了系统的性能。

MHD0815的博客 295

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

优快云独家首发!万字长文,YOLOv5/v7/v8算法模型yaml文件史上最详细解析与教程!小白也能看懂!掌握了这个就掌握了魔改YOLO的核心!

🍀🍀🍀YOLOv5/v7/v8算法模型yaml文件史上最详细解析与教程,全网最强,学不会算我输!!!

Coding... 1万+

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

系规备考论文:论IT服务规划设计

系规备考论文:论IT服务规划设计

liuxu324的博客 1144

Dify搭建AI测试用例生成器

1、获取产品需求文档2、解读、分析、挖掘需求点,提炼为测试点3、依据测试点,生成详细的测试用例4、输出测试用例1、打开 Dify 控制台,依次点击【工作室】-【ChatFlow】-【创建空白应用】。

十二测试录 1370

poj 3356 AGTC 简单dp

//poj 3356 //sep9 #include using namespace std; const int MAXN=1024; char a[MAXN],b[MAXN]; int dp[MAXN][MAXN]; int main() { int lenA,lenB; while(scanf("%d%s%d%s",&lenA,&a[1],&lenB,&b[1])!=EOF){

sepNINE的专栏 487

MATLAB算法实战应用案例精讲-【数模应用】校准曲线(附MATLAB、python和R语言代码实现)

模型校准曲线(Calibration Curve),也称为可靠性曲线(Reliability Curve)或概率校准曲线(Probability Calibration Curve),是一种评估分类模型输出概率准确性的图形工具。它可以帮助我们理解模型的预测概率是否与实际标签的分布一致。校准曲线通常包括以下步骤:计算模型预测概率:对于测试集中的每个样本,模型会输出一个概率值,表示样本属于正类的概率。将数据分桶:将这些概率值分成若干个等宽的桶(例如10个桶),每个桶中的样本具有相似的预测概率。

qq_36130719的博客 556

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

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

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

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

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

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

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

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

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

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

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 解题报告(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(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 解题心得

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

advyne9986的博客 170

poj 3356 AGTC(线性dp)

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

aqjh9999的博客 132

POJ3356 AGTC DP

http://poj.org/problem?id=3356

u014445884的专栏 522
上一篇: (最大流) poj 1459 Power Network
下一篇: (有限物品背包问题) poj 1276 Cash Machine
Hashmat
博客等级 码龄16年 14粉丝 62原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值