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 heliwen at 2009-03-13 18:09:16 on Problem 2436
#include<stdio.h>
#include<string.h>
int count,N,D,K,max,sum;
int d[1001][16];
bool s[16];
void recur(int p)
{
	int i,flag;
	if(d[p][0]==0)
	{
		sum++;
		goto loop;
	}
	flag = 0;
	for(i = 1;i <= d[p][0];i++)
	{
	//	flag = 0;
		if(!s[d[p][i]])
		{
			s[d[p][i]] = 1;
			count++;
		}
		if(count>K)
		{
			count--;
			flag = 1;
			s[d[p][i]] = 0;
			break;
		}
	}
	if(!flag)
		sum++;
loop:;
	if(p < N)
	{
		//printf("%d %d\n",p,sum);
		recur(p+1);
		sum--;
	}
	else
	{
//		printf("%d %d\n",p,sum);
		if(max < sum)
			max = sum;
	}
}
int main()
{
	int i,j;
	while(scanf("%d%d%d",&N,&D,&K)!=EOF){
	for(i = 1;i <= N;i++)
	{
		scanf("%d",&d[i][0]);
		for(j = 1;j <= d[i][0];j++)
			scanf("%d",&d[i][j]);
	}
	memset(s,0,sizeof(s));
	max = 0;count = 0;sum = 0;
	recur(1);
	printf("%d\n",max);
	}
	return 0;
}
/*Sample Input
6 3 2
0
1 1
1 2
1 3
2 2 1
2 2 1
Sample Output
5
*/

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