题意:判断基因链是否匹配,匹配的双链数加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. ndroid网络(4):HttpClient必经之路----使用线程安全的单例模式HttpClient,及HttpClient和Application的融合

    上文简 单介绍了HttpClient和Tomcat服务器的交互,主角是HttpClient,然后它跟服务器交互有两种方式即get和post.所以这个 HttpClient就类似于电脑上用的浏览器.当我 ...

  2. poj 1012 Joseph (约瑟夫问题)

    Joseph Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 47657   Accepted: 17949 Descript ...

  3. C++中将string类型转换为int, float, double类型 主要通过以下几种方式:

      C++中将string类型转换为int, float, double类型 主要通过以下几种方式: # 方法一: 使用stringstream stringstream在int或float类型转换为 ...

  4. C#导出数据到Excel通用的方法类

    导出数据到Excel通用的方法类,请应对需求自行修改. 资源下载列表 using System.Data; using System.IO; namespace IM.Common.Tools { p ...

  5. linux中切换用户方式su和su -的区别

    Using su The  su  command allows users to open a terminal window, and from that terminal start a sub ...

  6. 初学JavaScript须知道的七件事

    1.1.缩略标记 //定义对象 //var car = new Object(); //car.colour = 'red'; //car.wheels = 4; //car.hubcaps = 's ...

  7. ASP.NET-FineUI开发实践-8

    上回模拟的是下拉grid,这回我把下拉grid和表格自动补全放一起了,实在是好做,但是也有很多要注意的,现在分享下,大家学习. 接上回 传送门  1. 有个tbxMyBox1_TriggerClick ...

  8. OD: File Vulnerabilities & Protocols & Fuzz

    IE.Office 等软件有个共同点,即用文件作为程序的主要输入,但攻击者往往会挑战程序员的假定和假设. 文件格式 Fuzz 就是利用畸形文件测试软件的稳健性,其流程一般包括: * 以一个正常文件作为 ...

  9. 去掉input【type=number】默认的上下箭头

    input::-webkit-inner-spin-button {-webkit-appearance: none;}input::-webkit-outer-spin-button {-webki ...

  10. java反射新的应用

    利用java反射动态修改运行中对象的私有final变量,不管有没有get方法获取这个私有final变量. spring aop 本质是cglib,动态代理 可以做很多事情 query.addCrite ...