当前位置:网站首页>hdu 1503 Advanced Fruits(最长公共子序列的应用)
hdu 1503 Advanced Fruits(最长公共子序列的应用)
2022-08-09 20:09:00 【51CTO】
题目: http://acm.hdu.edu.cn/showproblem.php?pid=1503
Advanced Fruits
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2134 Accepted Submission(s): 1088
Special Judge
Problem Description
The company "21st Century Fruits" has specialized in creating new sorts of fruits by transferring genes from one fruit into the genome of another one. Most times this method doesn't work, but sometimes, in very rare cases, a new fruit emerges that tastes like a mixture between both of them.
A big topic of discussion inside the company is "How should the new creations be called?" A mixture between an apple and a pear could be called an apple-pear, of course, but this doesn't sound very interesting. The boss finally decides to use the shortest string that contains both names of the original fruits as sub-strings as the new name. For instance, "applear" contains "apple" and "pear" (APPLEar and apPlEAR), and there is no shorter string that has the same property.
A combination of a cranberry and a boysenberry would therefore be called a "boysecranberry" or a "craboysenberry", for example.
Your job is to write a program that computes such a shortest name for a combination of two given fruits. Your algorithm should be efficient, otherwise it is unlikely that it will execute in the alloted time for long fruit names.
Input
Each line of the input contains two strings that represent the names of the fruits that should be combined. All names have a maximum length of 100 and only consist of alphabetic characters.
Input is terminated by end of file.
Output
For each test case, output the shortest name of the resulting fruit on one line. If more than one shortest name is possible, any one is acceptable.
Sample Input
Sample Output
分析:大意,寻找包含两个字符串所有单个字符的最短字符串。

联想到最长公共子序列,输出那个寻找最长公共子序列的路径就是最小的最大串。
处理好边界,第0行全部指向左边,第0列全部指向上边,这样使得最终的汇聚点是(0,0),也就是递归输出的终止点。
边栏推荐
- 威纶通触摸屏制作自定义弹出窗口的具体方法(3种)
- matlab neural network ANN classification
- URL Protocol 网页打开应用程序
- Word文档怎么输入无穷大符号∞
- Week 8 Deep learning for object detection
- Jmeter 使用正则表达式提取器将返回值全部保存到一个文件中
- 场效应管Mosfet之雷卯Leiditech对应英飞凌Infineon
- MySQL笔记-06 基础SQL操作
- 【Efficient Tools】Remote Control Software ToDesk (Favorites)
- 数据集成API如何成为企业数字化转型的关键?
猜你喜欢

Simulation of Water Temperature Control System Based on Fuzzy PID Controller

leetcode 二叉树的分层遍历1

DSPE-PEG-PDP,DSPE-PEG-OPSS,磷脂-聚乙二醇-巯基吡啶可减少肽的免疫原性

What are the benefits of enterprise data integration?How do different industries solve the problem of data access?

Win11找不到Internet Explore怎么办

poj 3070 Fibonacci(简单矩阵连乘)

数据集成API如何成为企业数字化转型的关键?

访问控制知识

Install Mysql8.0 on windos, and solve the problem of re-login exception ERROR 1045 (28000)

【图文并茂】如何进行Win7系统的重装
随机推荐
leetcode 二叉树的分层遍历1
LeetCode Daily Question (321. Create Maximum Number)
URL Protocol web page to open the application
[Graphic and textual] How to reinstall Win7 system
Number of daffodils within a thousand
消防安全培训|“蓝朋友”,开课了!
cad图纸怎么复制到word文档里面?Word里插CAD图怎么弄?
Install Mysql8.0 on windos, and solve the problem of re-login exception ERROR 1045 (28000)
10个 Istio 流量管理 最常用的例子,你知道几个?
基于Docker构建MySQL主从复制数据库
source install/setup.bash时出现错误
prometheus学习3Grafana部署及基本使用
Problems with compiling SIP with QGIS
Acrel5000web能耗系统在某学院的应用-Susie 周
智能家居设备安全分析技术综述
Word第一页空白页怎么删除?删除Word第一页空白页方法教程
蓝牙模块有哪些种类?BLE低功耗蓝牙模块有什么特点?
Word怎么制作双面席卡?使用Word制作双面席卡方法
真香|持一建证书央企可破格录取
不经意传输协议OT