sicily 1035. DNA matching
题意:判断基因链是否匹配,匹配的双链数加1,并要标记,下次比较不能重用!
解法: 打擂台法
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std; bool compute(string s1, string s2){
if(s1.length() != s2.length())
return false;
bool flag = false;
for(int i=;i<s1.length();i++){
flag =(abs(s1[i]-s2[i]) == || abs(s1[i]-s2[i]) == );
if(!flag)
break;
}
return flag;
}
vector<string> strands; int main(){
int caseNums;
cin >> caseNums;
while(caseNums--){
int rows;
string temp;
int result =; cin >> rows;
strands.resize(rows);
strands.clear();
for(int i=;i<=rows;i++){
cin >> temp;
strands.push_back(temp);
} for(int i=;i<strands.size();i++){
if(strands[i] =="")
continue;
for(int j=i+;j<strands.size();j++){
if(strands[j]=="")
continue;
if(compute(strands[i],strands[j]))
{
strands[i] ="";
strands[j] ="";
result++;
break;
}
}
}
cout<<result<<endl;
}
return ;
}
sicily 1035. DNA matching的更多相关文章
- <Sicily>Brackets Matching
一.题目描述 Let us define a regular brackets sequence in the following way: Empty sequence is a regular s ...
- 学习《Hardware-Efficient Bilateral Filtering for Stereo Matching》一文笔记。
个人收藏了很多香港大学.香港科技大学以及香港中文大学里专门搞图像研究一些博士的个人网站,一般会不定期的浏览他们的作品,最近在看杨庆雄的网点时,发现他又写了一篇双边滤波的文章,并且配有源代码,于是下载下 ...
- LeetCode题解-----Wildcard Matching
题目描述: '?' Matches any single character. '*' Matches any sequence of characters (including the empty ...
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driven'.
spring 配置文件报错报错信息:cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be ...
- [LeetCode] Repeated DNA Sequences 求重复的DNA序列
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...
- [LeetCode] Wildcard Matching 外卡匹配
Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. ...
- [LeetCode] Regular Expression Matching 正则表达式匹配
Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...
- DNA解链统计物理
来源:Kerson Huang, Lectures on Statistical Physics and Protein Folding, pp 24-25 把双链DNA解开就像拉拉链.设DNA有\( ...
- Beginning Scala study note(5) Pattern Matching
The basic functional cornerstones of Scala: immutable data types, passing of functions as parameters ...
随机推荐
- Ellipse常用快捷键
Ctrl+m:视窗大小变化 Ctrl+F6:在打开的文件件进行切换 Ctrl+F7:在资源窗口间切换Ctrl+F8:在各种模式下进行切换 Ctrl+e:选择某个打开的文件Shift+home:整行选取 ...
- SlidingMenu导入编译用法--Eclipse和IDEA
非常多側滑的应用都用的是开源库SlidingMenu, 效果不错,下面是我用上的效果图,因为近期换成了IDEA(IntelliJ)编辑器,昨天上网找了全部的教程都是关于在Eclipse导入的方法,摸索 ...
- SQLServer 工具技巧
SQLServerProfiler 的使用 http://www.jikexueyuan.com/course/1712.html
- 熟悉java堆内存和栈内存和mysql的insert语句中含有id的处理
java的堆内存和栈内存有什么区别呢? 如果mysql数据库表的id是递增的,如果没有插入id,则id自增,如果插入id,则插入什么就显示什么.
- (转)js arguments对象
在javascript中,不需要明确指出参数名,就能访问它们.如: function hi(){if(arguments[0]=="andy"){ return;}aler ...
- VS2010发布网站的基本步骤
1.首先建一个空文件夹,用来存放发布的程序:例如:WebTest 2.然后打开IIS--->右击--->添加网站,如下图所示: 图 1-1 ...
- AFNetworking3.0出现Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable
在发送请求后一直报错, 浏览器解析却没有问题, 所以基本可以确定是AFNetworking的问题 下面是解决方法: AFHTTPSessionManager *manager = [AFHTTPSes ...
- 使用poi3.9的jar输出excel
// 取得模板文件存放的路径 ReadFilePath = ServletActionContext.getServletContext().getRealPath(ExcelTemplateFile ...
- css3表格隔行变色和表格选中变颜色代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- html5中的一些小知识点(CSS)
1.点击a标签周围区域就可以进入超链接: a标签 的css样式中的 display属性设置为block 就可以了 2.文字左右居中: text-align 属性值为 center 3.文字上下居中: ...