题意:判断基因链是否匹配,匹配的双链数加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. Qt 内存泄漏测试

    在说Qt的内存测试之前,首先需要说明和肯定的一点是:Qt是绝对没有内存泄漏的,我们必须相信这一点. 接下来,说明一下基于Linux的Qt内存测试工具及其用法和说明: 一.内存测试工具Valgrind ...

  2. 简单dp --- HDU1248寒冰王座

    题目链接 这道题也是简单dp里面的一种经典类型,递推式就是dp[i] = min(dp[i-150], dp[i-200], dp[i-350]) 代码如下: #include<iostream ...

  3. hdu 5105

    题意: y=|a*x^3+b*x^2+c*x+d|    求y的最大值? 题目是bc上的,之前写的时候,没考虑0的情况(太笨了).... 水题吧.... AC代码: #include <iost ...

  4. linux的sudo apt-get install 和dpkg -i <package.deb>命令

    ubuntu统一的安装软件命令 sudo apt-get install ** sudo dpkg -i <package.deb>

  5. HTML5 学习

    1.<header> 标签定义文档的页眉(介绍信息) 标签是 HTML 5 中的新标签 <header> <h1>Welcome to my homepage< ...

  6. java.io.FileNotFoundException: class path resource [META-INF/xfire/services.xml] cannot be opened because it does not exist

    解决办法: maven创建项目时: META-INF目录下面新建一个xfire文件夹,把services.xml文件放到这个文件夹里,再将整个META-INF拷贝到WEB-INF中 clean一下工程 ...

  7. nginx+tomcat+memcached搭建服务器集群及负载均衡

    在实际项目中,由于用户的访问量很大的原因,往往需要同时开启多个服务器才能满足实际需求.但是同时开启多个服务又该怎么管理他们呢?怎样实现session共享呢?下面就来讲一讲如何使用tomcat+ngin ...

  8. 装饰(Decorator)模式

    1.装饰(Decorator)模式    动态给一个对象添加一些额外的职责.就增加功能来说,装饰模式比生成子类更为灵活.Component是定义一个对象接口.可以给这些对象动态地添加职责.Concre ...

  9. Swift - 42 - 类的基本使用

    import Foundation /* 1.class表示类的关键字 2.class后面表示类名 3.类名后面的大括号内表示类的内部 */ /* 1.属性封装了set和get方法 2.方法里面封装了 ...

  10. 使用CAEmitterLayer实现下雪效果

    效果图: 代码部分: #import "ViewController.h" @interface ViewController () @end @implementation Vi ...