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 heliwen at 2009-03-03 13:19:17 on Problem 1419
In Reply To:大牛帮忙看看,数据都对了,就是WA!!!!!!!!!! Posted by:hdjtdxacm at 2009-03-03 12:31:15
> #include<stdio.h>
> int ax[105],a[105];
> int s[105],d[105][100] ;
> int n,sum,max;
> void recur(int p)
> {
> 	int i,flag;
> 	for(s[p] = 0;s[p] <= 1;s[p]++)
> 	{
> 		ax[p] = s[p];
> 		flag = 0;
> 		if(s[p] == 0)
> 		{
> 			for(i = 1;i <=d[p][0];i++)
> 			{
> 				if(ax[d[p][i]] == 0)
> 				{
> 					flag = 1;
> 					break;
> 				}
> 			}
> 		}
> 		if(flag == 1)
> 			continue;
> 		if(flag == 0&&s[p] == 0)
>     		sum++;
> 		if(p < n) 
> 		{
> 			recur(p + 1);
> 	    	sum--;
> 		}
> 		else
> 		{
> 			if(max < sum)
> 			{
> 				max = sum;
> 				for(i = 1;i <= n;i++)
> 				{
> 					a[i] = ax[i];
> 				}
> 			}
> 		}
> 	}
> }
> int main()
> {
> 	int m,i,k,st,ed,temp;
> 	scanf("%d",&m);
> 	while(m--)
> 	{
> 		max = -1;sum = 0;
> 		scanf("%d%d",&n,&k);
> 		for(i = 1;i <= n;i++)
> 	    	d[i][0] = 0;
> 		for(i = 1;i <= k;i++)
> 		{
> 			scanf("%d%d",&st,&ed);
> 			if(st < ed)
> 			{
> 				temp = st;
> 				st = ed;
> 				ed = temp;
> 			}
> 			d[st][++d[st][0]] = ed;
> 		}
> 		recur(1);
> 		printf("%d\n",max);
> 		for(i = 1;i <= n;i++)
> 			if(a[i] == 0)
> 					printf("%d ",i);
> 		printf("\n");
> 	}
> 	return 0;
> }
> /*Sample Input
> 
> 1
> 6 8
> 1 2
> 1 3
> 2 4
> 2 5
> 3 4
> 3 6
> 4 6
> 5 6
> Sample Output
> 
> 3
> 1 4 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