Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

c++ac0ms

Posted by 983543692 at 2016-06-29 01:58:00 on Problem 1007
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator