(uva)1368DNA Consensus String(map)
来源:互联网 发布:快速软件开发平台 编辑:程序博客网 时间:2024/05/29 19:48
题意:给定n个字符串,求最小距离的串。
/* ***********************************************Author :Lu_ckyCreated Time :2016-6-15 8:43:17File Name :xiao.cpp************************************************ */#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>#define LL long longusing namespace std;const int SIZE=1e6+10;const int maxn=1<<30;char cmap[55][1010];int n,m;int solve(int x){map<char,int>mp;for(int i=0;i<n;i++){char ch=cmap[i][x];if(mp.find(ch)==mp.end())mp[ch]=1;else mp[ch]++;}map<char,int>::iterator it,ans;int Max=-maxn;for(it=mp.begin();it!=mp.end();it++){if((*it).second>Max){ans=it;Max=(*it).second;}}printf("%c",(*ans).first);return n-Max;}int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int T;scanf("%d",&T);for(int cas=1;cas<=T;cas++){scanf("%d%d",&n,&m);for(int i=0;i<n;i++)scanf("%s",cmap[i]);int ans=0;for(int i=0;i<m;i++)ans+=solve(i);printf("\n%d\n",ans);} return 0;}
0 0
- (uva)1368DNA Consensus String(map)
- UVA 1368 - DNA Consensus String
- uva 1368 DNA Consensus String
- Uva-1368-DNA Consensus String
- UVa 1368 DNA Consensus String
- UVA 1368 DNA Consensus String
- UVA 1368 DNA Consensus String
- UVa:1368 DNA Consensus String
- uva 1368 - DNA Consensus String
- UVa 1368 - DNA Consensus String
- UVa 1368 - DNA Consensus String
- UVa 1368 DNA Consensus String
- UVa 1368 - DNA Consensus String
- UVA - 1368 DNA Consensus String
- UVa 1368DNA Consensus String
- UVa 1368 - DNA Consensus String
- Uva 1368 DNA Consensus String
- 【Uva 1368】 DNA Consensus String
- String 中的format
- EDACN 论坛Xilinx 版帖子汇总
- EasyUITree实现树形结构Json串
- 10.4 异常与继承
- 项目经验分享——Java常用工具类集合
- (uva)1368DNA Consensus String(map)
- 百度地图定位模块
- 10.5 异常规范
- c++学习第三天
- Android关于AndroidManifest.xml详细分析
- (hadoop学习-3)Total Order Partitioner
- 常用的java工具类
- UIViewController的完整生命周期
- C#实现天气预报