UVA760 DNA Sequencing 题解
Content
给出两个小写字母组成的字符串,求两个字符串的最长公共子串,如有多个按字典序顺序输出,如没有输出 No common sequence.,每两组数据间输出一个空行,最后一组数据后不应输出空行。
数据范围:字符串长度不超过 \(300\)。
Solution
原本是奔着作为 SA 的练习题来的,结果看完题目之后,我:???这题目有紫题???
话归正题。由于本题字符串的长度只有 \(300\),因此我们可以直接暴力提取出两个字符串里面的所有子串,然后扫过去找两个字符串的公共子串,取所有公共子串的长度的最大值,然后再回去扫,把所有长度最大的公共子串丢进一个 vector 里面直接排序就可以了。
注意这道题目的特判和毒瘤的输出格式,因为这个我 WA 了好几发。
Code
namespace Solution {
string s, t;
map<string, int> mp;
iv Main() {
int kase = 0;
while(cin >> s >> t) {
mp.clear(), kase++;
if(kase > 1) puts("");
int lens = s.size(), lent = t.size(), ans = 0;
F(int, len, 1, lens) F(int, i, 0, lens - len) mp[s.substr(i, len)] |= 1;
F(int, len, 1, lent) F(int, i, 0, lent - len) mp[t.substr(i, len)] |= 2;
for(auto x : mp) if(x.se == 3) ans = max(ans, (int)x.fi.size());
if(!ans) puts("No common sequence.");
else {
vector<string> res;
for(auto x : mp) if((int)x.fi.size() == ans && x.se == 3) res.push_back(x.fi);
sort(res.begin(), res.end());
F(int, i, 0, (int)res.size() - 1) cout << res[i] << endl;
}
}
return;
}
}
UVA760 DNA Sequencing 题解的更多相关文章
- LibreOJ 题解汇总
目录 #1. A + B Problem #2. Hello, World! #3. Copycat #4. Quine #7. Input Test #100. 矩阵乘法 #101. 最大流 #10 ...
- Multiclonal Invasion in Breast Tumors Identified by Topographic Single Cell Sequencing
Title: Multiclonal Invasion in Breast Tumors Identified by Topographic Single Cell Sequencing 课题的目的 ...
- Bioinformatics Glossary
原文:http://homepages.ulb.ac.be/~dgonze/TEACHING/bioinfo_glossary.html Affine gap costs: A scoring sys ...
- N-Gram
N-Gram是大词汇连续语音识别中常用的一种语言模型,对中文而言,我们称之为汉语语言模型(CLM, Chinese Language Model). 中文名 汉语语言模型 外文名 N-Gram 定 ...
- PacBio下机数据解读
今天被人问起如何看懂三代的下机数据,虽然解决了别人的问题,但感觉自己还是没有搞透. 基本的目录结构: |-- HG002new_O1l_BP_P6_021315b_MB_100pM | |-- D01 ...
- 2016-6-15-de novo文献阅读
准备读四篇denovo的文献: Nature Biotechnology(2015) - Sequencing of allotetraploid cotton (Gossypium hirsutum ...
- TruSeq 应该指的是试剂盒名字 NEB
现在中心用的是NEB试剂盒,建库步骤更简单一些.TruSeq和NEB差不多,既可以建DNA又可以建RNA. TruSeq Technology TruSeq technology repres ...
- The top 100 papers Nature explores the most-cited research of all time.
The top 100 papers Nature explores the most-cited research of all time. The discovery of high-temper ...
- Disposable microfluidic devices: fabrication, function, and application Gina S. Fiorini and Daniel T
Disposable microfluidic devices: fabrication, function, and application Gina S. Fiorini and Daniel T ...
随机推荐
- 【JavaSE】集合
Java集合 2019-07-05 12:39:09 by冲冲 1. 集合的由来 通常情况下,程序直到运行时,才知道需要创建多少个对象.但在开发阶段,我们根本不知道到底需要多少个数量的对象,甚至不 ...
- could not extract ResultSet
使用jpa进行代码更新:update的时候发现代码出现了异常:could not extract ResultSet 在数据库看数据并没有更新,后发现更新操作需要加一个注解 注释:当设置nativeQ ...
- C++ 编译错误记录
C++ _ZSt28__throw_bad_array_new_lengthv1 编译错误 出现场景:类似代码 vector<vector<int>> grid = {{1, ...
- 【2020五校联考NOIP #7】伟大的卫国战争
题面传送门 题意: 数轴上有 \(n\) 个点,现在要在它们之间连 \(m\) 条边,第 \(i\) 条边连接 \(a_i,b_i\) 两个点. 现在你要钦定每条边连在数轴的上方还是下方,使得任意两条 ...
- Atcoder Grand Contest 030 F - Permutation and Minimum(DP)
洛谷题面传送门 & Atcoder 题面传送门 12 天以前做的题了,到现在才补/yun 做了一晚上+一早上终于 AC 了,写篇题解纪念一下 首先考虑如果全是 \(-1\) 怎么处理.由于我 ...
- 51-Intersection of Two Linked Lists
Intersection of Two Linked Lists My Submissions QuestionEditorial Solution Total Accepted: 72580 Tot ...
- 安装octave详解
1. 一些可以替换的库(可跳过) 默认的库安装libblas.dll.OpenBLAS-v2.6.0-0-54e7b37_dynamicarch_nt4(自动检测CPU类型) 在目录下<your ...
- 小程序https启用tls1.2
公司的web服务器是iis7,在开发微信小程序的时候,需要启用TLS1.2. 将下面的代码复制到文本,存为reg文档,双击搞定. Windows Registry Editor Version 5.0 ...
- 巩固javaweb的第二十七天
巩固内容 正则表达式: 5. 指定字符串的开始和结尾 正则表达式中字符串的开始和结束符如表 2.6 所示. 表 2.6 开 始 和 结 尾 字符 作 用 ^ 指定以某个字符串开始 $ 指定以某个字符串 ...
- A Child's History of England.38
CHAPTER 12 ENGLAND UNDER HENRY THE SECOND PART THE FIRST Henry Plantagenet, when he was but [only] t ...