#include<iostream> #include<cstdio> #include<list> #include<string> #include<cstring> #include<sstream> #include<cctype> #include<string.h> #include<algorithm> #include<cmath> #include<stack> #include<fstream> #include<cstdlib> #include<vector> #include<map> #include<set> #include<utility> #include<iomanip> #include<queue> #include<deque> #include<iterator> #include<assert.h> #include<bitset> #include<climits> #include<ctime> #include<complex> using namespace std; #define SET(a) memset(a,-1,sizeof(a)) #define ALL(a) a.begin(),a.end() #define CLR(a) memset(a,0,sizeof(a)) #define PB push_back #define PI acos(-1.0) #define max3(a,b,c) max(a,max(b,c)) #define min3(a,b,c) min(a,min(b,c)) #define READ freopen("input.txt", "r", stdin) #define WRITE freopen("output.txt", "w", stdout) #define LL long long #define S(a) scanf("%d",&a) #define S2(a,b) scanf("%d%d",&a,&b) #define KS printf("Case %d: ",kk++) #define MOD 1000000007 #define MX 100010 int main() { int a,b,tc,c,w,x,y,z,n,m,u,v,cnt,mx,mn,p,q,r,sum,g,t; string s[55],res; cin>>tc; while(cin>>n>>m) { res=""; for(int i=0;i<n;i++) cin>>s[i]; cnt=0; for(int i=0;i<m;i++) { a=c=g=t=0; for(int j=0;j<n;j++) if(s[j][i]=='A') a++; else if(s[j][i]=='C') c++; else if(s[j][i]=='G') g++; else if(s[j][i]=='T') t++; int mx=max(a,max(c,(max(g,t)))); cnt+=(n-mx); if(mx==a) res+="A"; else if(mx==c) res+="C"; else if(mx==g) res+="G"; else if(mx==t) res+="T"; } cout<<res<<endl; cout<<cnt<<endl; } return 0; }
Sunday, 3 March 2013
UVa 1368 - DNA Consensus String Solution
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment