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:这是怎么回事?我觉得我的算法很好的啊?为什么总是WA呢?请高手指点!!

Posted by frkstyc at 2005-04-30 00:04:10 on Problem 2419
In Reply To:这是怎么回事?我觉得我的算法很好的啊?为什么总是WA呢?请高手指点!! Posted by:dxm at 2005-04-29 23:57:51
wa就不是“很好的”,玩字符串有点玩过头了吧。正经些的写法更容易调试。

> #include <iostream>
> #include <algorithm>
> 
> using namespace std;
> 
> #define MAXNUM 110
> 
> void main()
> {
> 	int m, n;
> 	char a[MAXNUM][MAXNUM] = {0};
> 	char j;
> 	int i, number, k, x;
> 	cin>>n>>m;
> 	while(cin>>i>>j)
> 	{
> 		a[i - 1][strlen(a[i - 1])] = j;
> 	}
> 	for(k = 0; k < n; k++)
> 	{
> 		sort(a[k], a[k] + strlen(a[k]));
> 	}
> 	for(k = 0; k < n; k++)
> 	{
> 		if(!a[k][0] || a[k][0] == 's')
> 			continue;
> 		for(x = k + 1; x < n; x++)
> 			if(!strcmp(a[k], a[x]))
> 			{
> 				a[x][0] = 's';
> 			}
> 	}
> 	number = 0;
> 	for(k = 0; k < n; k++)
> 	{
> 		if(a[k][0] && a[k][0] != 's')
> 			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