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

Re:优化逆序数计算后认为本题瓶颈不在逆序数上,另外请0MS的提供一下经验

Posted by buaahanjunwei at 2010-11-24 20:06:59 on Problem 1007
In Reply To:Re:优化逆序数计算后认为本题瓶颈不在逆序数上,另外请0MS的提供一下经验 Posted by:scu_sadan at 2010-09-16 10:03:27
我的是零秒,不过觉得写的还是很冗余,姑且抛砖引玉吧。
#include<stdio.h>



#define LINE  1000

#define MAXC  51




int main()

{

	int n = 0;

	int m = 0;

		

	int i = 0;
	int j = 0;
	int k = 0;

	int sum[LINE] = {0};

	

	char dna[LINE][MAXC] = {'\0'};

	int assist[26] = {0};

	

	scanf("%d%d" , &n , &m);

	

	for(i=0 ; i<m ; i++)

		scanf("%s" , dna[i]);

	for(i=0 ; i<m ; i++)

	{

		assist['A'-0x41] = 0;

		assist['C'-0x41] = 0;

		assist['G'-0x41] = 0;

		assist['T'-0x41] = 0;

		sum[i] = 0;

		for(j=n-1 ; j>=0 ; j--)

		{

			switch( dna[i][j] )

			{

			case 'A':

				assist['A'-0x41]++;

				break;

			case 'C':

				assist['C'-0x41]++;

				sum[i] += assist['A'-0x41];

				break;

			case 'G':

				assist['G'-0x41]++;

				sum[i] += (assist['A'-0x41] + assist['C'-0x41]);

				break;

			case 'T':

				assist['T']++;

				sum[i] += (assist['A'-0x41] + assist['C'-0x41] + assist['G'-0x41]);

				break;

			}

		}

	}

	for(i=0 ; i<m ; i++)

	{
		for(j=0 ; j<m ; j++)

			if(sum[j] != -1)

			{

				k = j;

				break;

			}

		for(j=0 ; j<m ; j++)

		{

			if( (sum[j]!=-1) && (sum[j] < sum[k]) )

				k = j;

		}

		printf("%s\n" , dna[k]);
		sum[k] = -1;
	}
}


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