题意:判断基因链是否匹配,匹配的双链数加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的更多相关文章

  1. <Sicily>Brackets Matching

    一.题目描述 Let us define a regular brackets sequence in the following way: Empty sequence is a regular s ...

  2. 学习《Hardware-Efficient Bilateral Filtering for Stereo Matching》一文笔记。

    个人收藏了很多香港大学.香港科技大学以及香港中文大学里专门搞图像研究一些博士的个人网站,一般会不定期的浏览他们的作品,最近在看杨庆雄的网点时,发现他又写了一篇双边滤波的文章,并且配有源代码,于是下载下 ...

  3. LeetCode题解-----Wildcard Matching

    题目描述: '?' Matches any single character. '*' Matches any sequence of characters (including the empty ...

  4. 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 ...

  5. [LeetCode] Repeated DNA Sequences 求重复的DNA序列

    All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...

  6. [LeetCode] Wildcard Matching 外卡匹配

    Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. ...

  7. [LeetCode] Regular Expression Matching 正则表达式匹配

    Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...

  8. DNA解链统计物理

    来源:Kerson Huang, Lectures on Statistical Physics and Protein Folding, pp 24-25 把双链DNA解开就像拉拉链.设DNA有\( ...

  9. Beginning Scala study note(5) Pattern Matching

    The basic functional cornerstones of Scala: immutable data types, passing of functions as parameters ...

随机推荐

  1. Tomcat jdbc pool配置

    Tomcat jdbc pool是apache在tomcat7版本中启用的新连接池,用它来解决以往DBCP无法解决的一些问题. Tomcat jdbc pool的优点: (1)    tomcat j ...

  2. Bzoj3990 [SDOI2015]排序

    Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 651  Solved: 338 Description 小A有一个1-2^N的排列A[1..2^N], ...

  3. int? 类型数据

    在数据库操作中,会遇到在int的单元格恰好为NULL值的情况,这个时候我们可以直接判断是否为null然后进行赋值,有人就想那我刚好用一下:?表达式不就好了: ) ? ); 这时候编译器会报错,原因就是 ...

  4. SpringMVC07处理器方法的返回值

    <body> <!--返回值是string的内部视图 --> <a href="user/add">add</a> <!--返 ...

  5. 排序算法之快速排序 JAVA快速排序算法

    public static void quickSort(int[] arr, int low , int height){ int l=low, h = height; if(low < he ...

  6. (转)ASP.NET 2.0中的partial

    1. 什么是局部类型? C# 2.0 引入了局部类型的概念.局部类型允许我们将一个类.结构或接口分成几个部分,分别实现在几个 不同的.cs文件中. 局部类型适用于以下情况: (1) 类型特别大,不宜放 ...

  7. DELL R410升级网卡驱动

    官方链接http://zh-cn.broadcom.com/support/ethernet_nic/netxtremeii.php(官方驱动的名字偶尔会改)   注意确保服务器的kernel-dev ...

  8. expr的简单应用

    expr命令 是一个手工命令行计数器,用于在UNIX/LINUX下求表达式变量的值,一般用于整数值,也可用于字符串. –格式为: expr expression_r(命令读入Expression 参数 ...

  9. Javascript 常用函数【3】

    jquery选中radio //如果之前有选中的,则把选中radio取消掉 $("#tj_cat .pro_category").each(function() { if ($(t ...

  10. linux内核学习之进程管理------task_struct结构体

    struct task_struct { volatile long state;    /* -1 unrunnable, 0 runnable, >0 stopped */ struct t ...