Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
c++ac0ms#include<iostream> #include<string> #include<cstring> #include<algorithm> using namespace std; struct Cstring{ char s[60]; int v,index; bool operator<(const Cstring&s1)const { return v<s1.v; } }que[1000]; int rev(char s[]) { int ans1=0,A=0,C=0,G=0,T=0; for(int i=strlen(s)-1;i>=0;--i) { switch(s[i]) { case 'A':A++;break; case 'C':C++;ans1+=A;break; case 'G':G++;ans1+=A+C;break; case 'T':T++;ans1+=A+C+G;break; default:break; } } return ans1; } int main() { int n,m; scanf("%d%d",&m,&n); for(int i=0;i<n;++i)scanf("%s",que[i].s),que[i].v=rev(que[i].s); stable_sort(que,que+n); for(int i=0;i<n;++i)printf("%s\n",que[i].s); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator