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

Why wrong answer???

Posted by sutekine at 2008-05-25 08:07:17 on Problem 1007
There is my source code.

#include<stdio.h>
#include<stdlib.h>

char DNA[110][55];
struct node{
	int ind, inversion;
};

int compare( const void *a, const void *b )
{
	node *pa = (node *)a;
	node *pb = (node *)b;
	return (pa->inversion * 1000 + pa->ind) - (pb->inversion * 1000 + pb->ind);
}

node temp[55];

int main(void)
{
	int i, j, k, n, m;
	scanf("%d %d", &n, &m);
	for( i = 0 ; i < m ; i++ )
		scanf("%s", DNA[i]);
	for( i = 0 ; i < m ; i++ ){
		temp[i].ind = i;
		for( j = 0 ; j < n - 1; j++ ){
			for( k = j + 1 ; k < n ; k++ ){
				if( DNA[i][j] > DNA[i][k] ) temp[i].inversion++;
			}
		}
	}
	qsort( temp, m, sizeof(node), compare );
	for( i = 0 ; i < m ; i++ )
		printf("%s\n", DNA[temp[i].ind]);
	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