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

wrong answer, but i dont understand why

Posted by acao11 at 2009-02-20 10:00:15 on Problem 1007
why is not it correct ? Can somebody find an input such that the output is wrong ?

Thanks

#include <cstdio>

using namespace std; 

int main()
{
	int N, L, M, i, j, k, l, o;
	scanf("%d %d", &L, &N);

	char** dnas = new char*[N];
	int* Ms = new int[N];
	
	memset(Ms, 0, sizeof(Ms));

	for (k = 0; k < N; k++)
	{
		dnas[k] = new char[L]; 
		scanf("%s", dnas[k]);
		//dnas[k] += '\0';
		for (i = 0; i < L; i++)
		{
			for (j = i+1; j < L ; j++)
			{
				if (dnas[k][i] > dnas[k][j])
					Ms[k]++;
			} 
		}
		if (k > 0) 
		{
			o = k;
			for (l = k-1; l >= 0; l--)
			{
				if (Ms[l] > Ms[o])
				{
					swap(Ms[l], Ms[o]);
					swap(dnas[l], dnas[o]);
					o = l;
				}
			}
		} 
	}

	for (k = 0; k < N; k++)
	{
		printf("%s\n", dnas[k], Ms[k]);
	}		
	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