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

(菜鸟请教 ) 测试数据中有什么特殊情况吗 稳定排序也有了 sample通过了 AAAAAAAA这种也没问题 可是就是WA 不知道为什么 谢谢

Posted by peterpan at 2005-10-11 22:40:49 on Problem 1007
#include "stdio.h"
#include <algorithm>
using namespace std;


int len,num;
char input[101][51];
int  order[51];//存放每个DNA序列的计数
int  ForSort[51];//这个是为了sort使用

bool compare(int a, int b)
{
	return order[a] < order[b];
}

int main(int argc, char* argv[])
{
	int i,j,k,t;

	//freopen("1007.txt", "r", stdin);
	scanf("%d %d",&len,&num);
	getchar();

	for( i=0;i<num;i++)
	{
		gets(input[i]);
		//以下代码 计算out of order
		for( j=0;j<len;j++)
		{
			for( k=j;k<len;k++)
			     if(input[i][j] > input[i][k]  )//出现了不合序列
				order[i] ++;
		}
		ForSort[i]= i;
	}
	//稳定排序
	stable_sort(ForSort,ForSort+num,compare);//按照order的内容排序 改变的是input数组的下标序列

	for(i=0;i<num;i++)
	{
		printf("%s\n",input[ForSort[i]]);
	}

	return 0;
}

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