题意:判断基因链是否匹配,匹配的双链数加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. Sql排名和分组排名

    在很多时候,都有排名这个功能,比如排行榜,并且还需要分页的功能,一般可以再select的时候按照某一字段 oorder by XX desc,这样limit 查找就可以得到排名信息,但是有时候是需要多 ...

  2. 递归---NYOJ-176 整数划分(二)和NYOJ-279队花的烦恼二

    这道题目的递归思想和第一个题差不多, 主要思想是:func(n, m)的作用是将n划分为m个. 1. 如果n < m 的时候肯定是不能划分的,所以就返回0 2. 如果m = 1 或者 n = m ...

  3. C#几种截取字符串的方法小结,需要的朋友可以参考一下

    1.根据单个分隔字符用split截取 例如 复制代码 代码如下: string st="GT123_1"; string[] sArray=st.split("_&quo ...

  4. FFMPEG 视频旋转设置

    fmpeg -i inputfile.mp4 -vf "transpose=1" outputfile.mp4 0=90CounterCLockwise and Vertical ...

  5. (转)用eclipse创建一个j2ee的web工程后,左面projects窗口中的项目如何没有显示webRoot文件夹,除了src的文件夹,其他都不显示

    左边目录窗口的右上方,有个向下的箭头,点里面的filters,把所有的勾都去掉看看

  6. 张羿给的删除重复数据的mssql语句

    select count(1), gsdm, idfrom ods_sc.T_D_DEVICE_COMMONgroup by gsdm, idhaving count(1) > 1; delet ...

  7. iOS中枚举定义的三种方式

    最简单的方式 typedef enum{ num1 = 0, num2 = 1, num3 = 2 }num; 同时我们还可以使用NS_ENUM的方式定义枚举 typedef NS_ENUM (NSI ...

  8. Linux编程基础——GDB(设置断点)(转:TianFang,cnblog: http://www.cnblogs.com/TianFang/archive/2013/01/20/2868889.html)

    启动GDB后,首先就是要设置断点,程序中断后才能调试.在gdb中,断点通常有三种形式: 断点(BreakPoint): 在代码的指定位置中断,这个是我们用得最多的一种.设置断点的命令是break,它通 ...

  9. Socket 接收本地短连接并转发为长连接 多线程

    import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io. ...

  10. phpcms v9联动菜单实现筛选

    <!--初始化init--> {php $theurl = "index.php?m=content&c=index&a=lists&catid=$cat ...