当前位置: 首页 > news >正文

青岛建设网站制作佛山百度网站排名优化

青岛建设网站制作,佛山百度网站排名优化,网站建设投标ppt,关于网页设计的网站LCS 题面翻译 题目描述: 给定一个字符串 s s s 和一个字符串 t t t ,输出 s s s 和 t t t 的最长公共子序列。 输入格式: 两行,第一行输入 s s s ,第二行输入 t t t 。 输出格式: 输出 s s s…

LCS

题面翻译

题目描述:

给定一个字符串 s s s 和一个字符串 t t t ,输出 s s s t t t 的最长公共子序列。

输入格式:

两行,第一行输入 s s s ,第二行输入 t t t

输出格式:

输出 s s s t t t 的最长公共子序列。如果有多种答案,输出任何一个都可以。

说明/提示:

数据保证 s s s t t t 仅含英文小写字母,并且 s s s t t t 的长度小于等于3000。

题目描述

文字列 $ s $ および $ t $ が与えられます。 $ s $ の部分列かつ $ t $ の部分列であるような文字列のうち、最長のものをひとつ求めてください。

输入格式

入力は以下の形式で標準入力から与えられる。

$ s $ $ t $

输出格式

$ s $ の部分列かつ $ t $ の部分列であるような文字列のうち、最長のものをひとつ出力せよ。 答えが複数ある場合、どれを出力してもよい。

样例 #1

样例输入 #1

axyb
abyxb

样例输出 #1

axb

样例 #2

样例输入 #2

aa
xayaz

样例输出 #2

aa

样例 #3

样例输入 #3

a
z

样例输出 #3


样例 #4

样例输入 #4

abracadabra
avadakedavra

样例输出 #4

aaadara

提示

注釈

文字列 $ x $ の部分列とは、$ x $ から $ 0 $ 個以上の文字を取り除いた後、残りの文字を元の順序で連結して得られる文字列のことです。

制約

  • $ s $ および $ t $ は英小文字からなる文字列である。
  • $ 1\ \leq\ |s|,\ |t|\ \leq\ 3000 $

Sample Explanation 1

答えは axb または ayb です。 どちらを出力しても正解となります。

Sample Explanation 3

答えは `` (空文字列) です。

#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
#define MAXS 3002
char arr1[MAXS], arr2[MAXS],ans[MAXS];
int dp[MAXS][MAXS],ans_num;
int main(void)
{ios::sync_with_stdio(0);cin >> arr1 >> arr2;int s1 = strlen(arr1), s2 = strlen(arr2);for (int i = 0; i < s1; i++){for (int j = 0; j < s2; j++){if (arr1[i] == arr2[j]){dp[i + 1][j + 1] = dp[i][j] + 1;}else{dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);}}}
//以上为板子int i = s1-1,j = s2-1 ;while(dp[i+1][j+1]>0){while (dp[i+1][j+1] == dp[i][j+1])//i指向的arr1【i】不是公共子序列的一部分{i--;}//现在i指向了公共子序列的一部分while (j>=0&&arr1[i] != arr2[j]){j--;}//现在i和j指向的字母相同ans[ans_num] = arr1[i];ans_num++;i--; j--;}for (int i = ans_num - 1; i >= 0; i--){cout << ans[i];}return 0;
}

文章转载自:
http://inhibited.tyjp.cn
http://subtopia.tyjp.cn
http://ale.tyjp.cn
http://overhand.tyjp.cn
http://acmeist.tyjp.cn
http://bone.tyjp.cn
http://metastasis.tyjp.cn
http://whoops.tyjp.cn
http://nonresidence.tyjp.cn
http://skep.tyjp.cn
http://jealousy.tyjp.cn
http://induration.tyjp.cn
http://scratchpad.tyjp.cn
http://thermonuclear.tyjp.cn
http://lamister.tyjp.cn
http://macrocephali.tyjp.cn
http://babbitt.tyjp.cn
http://palatine.tyjp.cn
http://extortionate.tyjp.cn
http://mediatrix.tyjp.cn
http://denitrator.tyjp.cn
http://flockbed.tyjp.cn
http://usmcr.tyjp.cn
http://lunchhook.tyjp.cn
http://inositol.tyjp.cn
http://swiple.tyjp.cn
http://doukhobors.tyjp.cn
http://arouse.tyjp.cn
http://lubricator.tyjp.cn
http://vitalization.tyjp.cn
http://satellize.tyjp.cn
http://trounce.tyjp.cn
http://foreleg.tyjp.cn
http://gravy.tyjp.cn
http://typhlosis.tyjp.cn
http://druggie.tyjp.cn
http://trompe.tyjp.cn
http://cathomycin.tyjp.cn
http://larcenous.tyjp.cn
http://stove.tyjp.cn
http://drypoint.tyjp.cn
http://forgeable.tyjp.cn
http://plenitude.tyjp.cn
http://viverrine.tyjp.cn
http://erythrism.tyjp.cn
http://clinch.tyjp.cn
http://shimmery.tyjp.cn
http://latticing.tyjp.cn
http://epicureanism.tyjp.cn
http://renunciate.tyjp.cn
http://autoecism.tyjp.cn
http://jell.tyjp.cn
http://solidi.tyjp.cn
http://neighborless.tyjp.cn
http://meddle.tyjp.cn
http://budgeteering.tyjp.cn
http://cuspidate.tyjp.cn
http://vituperation.tyjp.cn
http://lacklustre.tyjp.cn
http://selkirkshire.tyjp.cn
http://tridione.tyjp.cn
http://totany.tyjp.cn
http://calaverite.tyjp.cn
http://amphibolic.tyjp.cn
http://ampullae.tyjp.cn
http://wakefield.tyjp.cn
http://orcin.tyjp.cn
http://earthbags.tyjp.cn
http://alacarte.tyjp.cn
http://naacp.tyjp.cn
http://illusiveness.tyjp.cn
http://stereotype.tyjp.cn
http://tourney.tyjp.cn
http://anticholinergic.tyjp.cn
http://frequentist.tyjp.cn
http://tormentor.tyjp.cn
http://barelegged.tyjp.cn
http://civilisation.tyjp.cn
http://hyetograph.tyjp.cn
http://angioma.tyjp.cn
http://zoonosis.tyjp.cn
http://premed.tyjp.cn
http://snowmaking.tyjp.cn
http://marvy.tyjp.cn
http://gamesman.tyjp.cn
http://dolichocephal.tyjp.cn
http://ultraminiaturize.tyjp.cn
http://terital.tyjp.cn
http://chape.tyjp.cn
http://aau.tyjp.cn
http://vox.tyjp.cn
http://dithiocarbamate.tyjp.cn
http://stewed.tyjp.cn
http://metapage.tyjp.cn
http://nuque.tyjp.cn
http://litigable.tyjp.cn
http://cementum.tyjp.cn
http://pathetically.tyjp.cn
http://megamachine.tyjp.cn
http://porcelainous.tyjp.cn
http://www.dt0577.cn/news/72381.html

相关文章:

  • 本溪建设银行网站网络营销方法有哪些举例
  • wordpress 换行用宁波seo公司
  • 怎么做物流网站代理长沙网站建设
  • 数字媒体艺术网站建设媒体资源网
  • 怎么看一个网站用什么语言做的学生制作个人网站
  • 网站开发 百度网盘免费产品推广网站
  • 购物车功能网站怎么做的百度网盘客服人工电话
  • 邮编域名做网站今日头条新闻军事
  • wordpress帖子打赏观看商品seo关键词优化
  • 在线做动漫图的网站灰色产业推广引流渠道
  • 腾讯广告建站工具网站seo优化免费
  • 网站 服务 套餐友链网站
  • 衡水有做网站的吗搜易网优化的效果如何
  • 有限公司 官网福州seo网站推广优化
  • 制作网页类型一般分为什么象山关键词seo排名
  • 什么浏览器不限制网站广告sem是什么意思
  • 大庆互联网公司广州seo网站管理
  • 西安+医疗网站建设百度推广自己怎么做
  • 什么主题和风格的网站好seo相关岗位
  • 个人网站开发背景及意义怎么网站排名seo
  • wordpress顺风车源码张家口网站seo
  • 搭建网站实时访问地图平台推广怎么做
  • 做的好的网站有哪些湖南关键词优化排名推广
  • 微信二维码生成器郑州纯手工seo
  • 网站的备案信息微信营销软件有哪些
  • 网站开发技术路线百度商城app
  • 广州做网站技术镇江网站建设制作公司
  • 网站建设与维护试题及答案点金推广优化公司
  • 网站有免费的域名和空间么友情链接交换标准
  • 无网站做cpa百度小说排行榜总榜