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

帮忙看一下是怎么回事老是WA?

Posted by dxm at 2005-04-23 23:30:18 on Problem 2419
我的想法是把人看到的树放在一起,然后对这些树排序,再比较各个人看到的树的集合。相等一对就减掉1。
#include <iostream.h>
#include <string.h>

#define MAXNUM 100

void main()
{
	int m, n;
	char a[MAXNUM][MAXNUM] = {0};
	char i, j, t;
	int number, k, x, y, tt;
	cin>>n>>m;
	number = n;
	while(cin>>i>>j)
	{
		a[i - 1 - 48][strlen(a[i - 1 - 48])] = j;
	}
	for(k = 0; k < m; k++)
	{
		for(x = 0; x < strlen(a[k]); x++)
		{
			t = a[k][x];
			tt = x;
			for(y = x + 1; y < strlen(a[k]); y++)
			{
				if(a[k][y] < t)
				{
					t = a[k][y];
					tt = y;
				}
			}
			a[k][tt] = a[k][x];
			a[k][x] = t;
		}
	}
	for(k = 0; k < m; k++)
		for(x = k + 1; x < m; x++)
			if(!strcmp(a[k], a[x]))
				number--;

	cout<<number<<endl;
}

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