洛谷 P3670 [USACO17OPEN]Bovine Genomics S奶牛基因组(银)
题目描述
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.
输入输出样例
说明
感谢@ 秘密观测者 的提供翻译
思路:枚举
#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奶牛基因组(银)的更多相关文章
- 洛谷 [USACO17OPEN]Bovine Genomics G奶牛基因组(金) ———— 1道骗人的二分+trie树(其实是差分算法)
题目 :Bovine Genomics G奶牛基因组 传送门: 洛谷P3667 题目描述 Farmer John owns NN cows with spots and NN cows without ...
- 洛谷P3611 [USACO17JAN]Cow Dance Show奶牛舞蹈
题目描述 After several months of rehearsal, the cows are just about ready to put on their annual dance p ...
- 洛谷P3668 [USACO17OPEN]Modern Art 2 现代艺术2
P3668 [USACO17OPEN]Modern Art 2 现代艺术2 题目背景 小TY的同学HF也想创作艺术 HF只有一块长条状的画布(画条),所以每一次涂色只能涂上连续几个单位的颜料,同样新的 ...
- 洛谷 P3671 [USACO17OPEN]Where's Bessie? 贝西在哪呢
P3671 [USACO17OPEN]Where's Bessie? 贝西在哪呢 题目背景 农夫John正在测试一个他新发明的全自动寻找奶牛无人机,它能够照一张农场的图片然后自动找出奶牛的位置. 不幸 ...
- 洛谷 P3669 [USACO17OPEN]Paired Up 牛牛配对
P3669 [USACO17OPEN]Paired Up 牛牛配对 题目描述 Farmer John finds that his cows are each easier to milk when ...
- 洛谷P3052 [USACO12MAR]摩天大楼里的奶牛 [迭代加深搜索]
题目传送门 摩天大楼里的奶牛 题目描述 A little known fact about Bessie and friends is that they love stair climbing ra ...
- 洛谷P1341 最受欢迎的奶牛
题目描述 每头奶牛都梦想成为牛棚里的明星.被所有奶牛喜欢的奶牛就是一头明星奶牛.所有奶 牛都是自恋狂,每头奶牛总是喜欢自己的.奶牛之间的“喜欢”是可以传递的——如果A喜 欢B,B喜欢C,那么A也喜欢C ...
- 洛谷P3052 [USACO12MAR]摩天大楼里的奶牛Cows in a Skyscraper
P3052 [USACO12MAR]摩天大楼里的奶牛Cows in a Skyscraper 题目描述 A little known fact about Bessie and friends is ...
- 洛谷 P3052 [USACO12MAR]摩天大楼里的奶牛Cows in a Skyscraper
题目描述 A little known fact about Bessie and friends is that they love stair climbing races. A better k ...
随机推荐
- 【剑指Offer面试题】 九度OJ1371:最小的K个数
题目链接地址: http://ac.jobdu.com/problem.php?pid=1371 题目1371:最小的K个数 时间限制:1 秒内存限制:32 兆特殊判题:否提交:5938解决:1265 ...
- HDU-3577-Fast Arrangement-区间更新
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3577 好吧,我认为这道题有必要说一下题目意思:毕竟我刚開始是没有看太懂,原谅我这个英语渣渣...ORZ ...
- hibernate动态表名映射--仅仅有想不到,没有做不到
近期的一个项目有一个需求,有N个考核单位,要对每一个考核单位生成一张考核情况表.这样做的目的是横切数据库,这这个需求的实现中,我的组员遇到了一个技术问题,我将我的解决的方法和整个思考过程与大家分享, ...
- bzoj3438: 小M的作物(那年花开最小割)
3438: 小M的作物 题目:传送门 题解: 最小割标准水题(做了几天的最小割之后表示是真的水) 为什么水:博主已经做过两道基本一样的题目了... 详情参考:bzoj3894 代码: #include ...
- Find or Query Data with C# Driver
https://docs.mongodb.com/getting-started/csharp/query/ Overview You can use the Find and FindAsync m ...
- android删除表和清空表
删除某一表: //删除某一个表 public void dropTable(SQLiteDatabase db){ db.execSQL("drop from tab_name") ...
- <a>标签是什么意思 怎么使用?
转自:https://www.imooc.com/qadetail/190881 (1) a标签的作用:超链接,用于跳转到别的网页. (2) a标签的用法:<a href="网址&qu ...
- PostgreSQL Replication之第三章 理解即时恢复(1)
到现在为止,您已经掌握了一定的理论.因为生活不仅由理论组成(它可能同样重要),是时候深入实际的工作了. 本章的目标是让您明白如何恢复数据到一个给定的时间点.当您的系统崩溃或者有人意外地删除了一个表,不 ...
- E. Reachability from the Capital(tarjan+dfs)
求联通分量个数,在dfs一次 #include <iostream> #include <algorithm> #include <cstring> #includ ...
- SSD-tensorflow-2 evaluation
测试就是用voc2007的test set来测试已经训练好的checkpoint的mAP,github上提供了三个已经训练好的model的checkpoint checkpoint 里面已有的300_ ...