题目描述

Farmer John owns NN cows with spots and NN cows without spots. Having just completed a course in bovine genetics, he is convinced that the spots on his cows are caused by mutations in the bovine genome.

At great expense, Farmer John sequences the genomes of his cows. Each genome is a string of length MM built from the four characters A, C, G, and T. When he lines up the genomes of his cows, he gets a table like the following, shown here

for N=3N=3:

Positions: 1 2 3 4 5 6 7 ... M

Spotty Cow 1: A A T C C C A ... T
Spotty Cow 2: G A T T G C A ... A
Spotty Cow 3: G G T C G C A ... A Plain Cow 1: A C T C C C A ... G
Plain Cow 2: A G T T G C A ... T
Plain Cow 3: A G T T C C A ... T

Looking carefully at this table, he surmises that positions 2 and 4 are sufficient to explain spottiness. That is, by looking at the characters in just these two positions, Farmer John can predict which of his cows are spotty and which are not (for example, if he sees G and C, the cow must be spotty).

Farmer John is convinced that spottiness can be explained not by just one or two positions in the genome, but by looking at a set of three distinct positions. Please help him count the number of sets of three distinct positions that can each explain spottiness.

FJ有n头有斑点的牛和n头没有斑点的牛。由于他刚刚学完牛的基因学的课程,他想知道牛有没有斑点是否

与牛的基因有关。

FJ花了巨大的代价测出了每个牛的基因,每头牛的基因用一个长度为M的由“A,C,G,T”的串构成。FJ将这

些串写成一个表/矩阵,就像图中这样

(N=3的例子)

FJ仔细的观察这个表,他发现通过观测2,4位置的字符串可以预测牛是否有斑点。

(在这个例子中,假如他看到24位置是GC、AT或者AC就可以断定其有斑点,因为1号有斑点的牛24位置基因为AC,2号为AT,3号为GC,而且没有任何一头无斑点的牛的24位置出现过这三个串)

FJ认为,1个或者两个位点是不能够区分品种的,必须是刚好3个位点。他想知道能用多少组三个本质不同的位置判断牛的斑点,{1,2,3}和{1,3,2}是本质相同的

输入输出格式

输入格式:

The first line of input contains NN (1 \leq N \leq 5001≤N≤500) and MM (3 \leq M \leq 503≤M≤50). The next NN lines each contain a string of MMcharacters; these describe the genomes of the spotty cows. The final NN lines describe the genomes of the plain cows.

输出格式:

Please count the number of sets of three distinct positions that can explain spottiness. A set of three positions explains spottiness if the spottiness trait can be predicted with perfect accuracy among Farmer John's population of cows by looking at just those three locations in the genome.

输入输出样例

输入样例#1: 复制

3 8
AATCCCAT
GATTGCAA
GGTCGCAA
ACTCCCAG
ACTCGCAT
ACTTCCAT
输出样例#1: 复制

22

说明

感谢@ 秘密观测者 的提供翻译

思路:枚举

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,ans;
char s[];
int map[][],tmp[][][];
int work(char c){
if(c=='A') return ;
if(c=='T') return ;
if(c=='G') return ;
if(c=='C') return ;
}
int main(){
scanf("%d%d",&n,&m);
for(int i=;i<=*n;i++){
scanf("%s",s);
for(int j=;j<m;j++)
map[i][j+]=work(s[j]);
}
for(int i=;i<=m-;i++)
for(int j=i+;j<=m-;j++)
for(int k=j+;k<=m;k++){
bool flag=;
memset(tmp,,sizeof(tmp));
for(int l=;l<=n;l++)
tmp[map[l][i]][map[l][j]][map[l][k]]=;
for(int l=n+;l<=*n;l++)
if(tmp[map[l][i]][map[l][j]][map[l][k]]){ flag=;break; }
if(!flag) ans++;
}
cout<<ans;
}

洛谷 P3670 [USACO17OPEN]Bovine Genomics S奶牛基因组(银)的更多相关文章

  1. 洛谷 [USACO17OPEN]Bovine Genomics G奶牛基因组(金) ———— 1道骗人的二分+trie树(其实是差分算法)

    题目 :Bovine Genomics G奶牛基因组 传送门: 洛谷P3667 题目描述 Farmer John owns NN cows with spots and NN cows without ...

  2. 洛谷P3611 [USACO17JAN]Cow Dance Show奶牛舞蹈

    题目描述 After several months of rehearsal, the cows are just about ready to put on their annual dance p ...

  3. 洛谷P3668 [USACO17OPEN]Modern Art 2 现代艺术2

    P3668 [USACO17OPEN]Modern Art 2 现代艺术2 题目背景 小TY的同学HF也想创作艺术 HF只有一块长条状的画布(画条),所以每一次涂色只能涂上连续几个单位的颜料,同样新的 ...

  4. 洛谷 P3671 [USACO17OPEN]Where's Bessie? 贝西在哪呢

    P3671 [USACO17OPEN]Where's Bessie? 贝西在哪呢 题目背景 农夫John正在测试一个他新发明的全自动寻找奶牛无人机,它能够照一张农场的图片然后自动找出奶牛的位置. 不幸 ...

  5. 洛谷 P3669 [USACO17OPEN]Paired Up 牛牛配对

    P3669 [USACO17OPEN]Paired Up 牛牛配对 题目描述 Farmer John finds that his cows are each easier to milk when ...

  6. 洛谷P3052 [USACO12MAR]摩天大楼里的奶牛 [迭代加深搜索]

    题目传送门 摩天大楼里的奶牛 题目描述 A little known fact about Bessie and friends is that they love stair climbing ra ...

  7. 洛谷P1341 最受欢迎的奶牛

    题目描述 每头奶牛都梦想成为牛棚里的明星.被所有奶牛喜欢的奶牛就是一头明星奶牛.所有奶 牛都是自恋狂,每头奶牛总是喜欢自己的.奶牛之间的“喜欢”是可以传递的——如果A喜 欢B,B喜欢C,那么A也喜欢C ...

  8. 洛谷P3052 [USACO12MAR]摩天大楼里的奶牛Cows in a Skyscraper

    P3052 [USACO12MAR]摩天大楼里的奶牛Cows in a Skyscraper 题目描述 A little known fact about Bessie and friends is ...

  9. 洛谷 P3052 [USACO12MAR]摩天大楼里的奶牛Cows in a Skyscraper

    题目描述 A little known fact about Bessie and friends is that they love stair climbing races. A better k ...

随机推荐

  1. pandas dataframe 做机器学习训练数据=》直接使用iloc或者as_matrix即可

    样本示意,为kdd99数据源: 0,udp,private,SF,105,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0.00,0.00,0.00,0.00,1.0 ...

  2. jzoj3454 表白(love)解题报告(01分数规划+DP)

    题目链接:https://jzoj.net/senior/#contest/show/2414/2 题目描述: 鸡腿是CZYZ的著名DS,但是不想追妹子的DS不是好GFS,所以鸡腿想通过表白来达到他追 ...

  3. 21.hash_map(已被废弃不再使用 被unordered_map代替)

    #include <string> //老版本的unordered_map(已经废弃不再使用) #include <hash_map> #include <iostrea ...

  4. 3.c语言结构体成员内存对齐详解

    一.关键一点 最关键的一点:结构体在内存中是一个矩形,而不是一个不规则形状 二.编程实战 #include <stdlib.h> #include <stdio.h> stru ...

  5. ListView有Header时的position情况

     问题: headerView 为第0个view,item 的 pos会从1开始. 解决方式: position减去 listView.getHeaderViewsCount().例如我想得到list ...

  6. ORM原理

    原理: 1.实现JavaBean的属性到数据库表的字段的映射:        --通过配置文件将JavaBean的属性与数据库表的字段的关联起来 2.映射关系:   一对多,多对一等 持久层(Pers ...

  7. HTML5按键打开摄像头和拍照

    HTML5实现按键打开摄像头和拍照 步骤: 1.创建一个打开摄像头按钮的标签.video标签.拍照的按钮标签.画布 2.实现打开摄像头的功能 3.实现拍照功能   具体实现代码: <!DOCTY ...

  8. [HNOI2004]高精度开根

    题目:洛谷P2293.BZOJ1213. 题目大意:给你$n,k(n\leq 10^{10000},k\leq 50)$,求$\lfloor \sqrt[k]{n}\rfloor$. 解题思路:高精度 ...

  9. HDU 4398 Template Library Management (最优页面调度算法)

    中等偏易题.操作系统理论中的最优页面调度算法,贪心.当需要淘汰某个模版时,淘汰掉当前手中在最远的将来才会被用到(或者以后永远不再用到)的那个. 代码: #include <iostream> ...

  10. WHU 1548 Home 2-SAT

    ---恢复内容开始--- 题意: N个人想回家在至少一个时刻.至多两个时刻.并且,他们每个人都能独自回家. 定义:ai表示第i个人回家的时间, xij = abs(ai - aj) (i != j). ...