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:关于这题,很无语!!!1

Posted by litstrong at 2009-09-02 22:37:46 on Problem 2425
In Reply To:关于这题,很无语!!!1 Posted by:nower at 2009-08-18 18:57:25
> WA的代码:#include"stdio.h"
> #include"string.h"
> int g[1001][1001],sg[1001],flag[1001];
> int n,m,num;
> void dfs(int p)
> {
> 	int i;
> 	memset(flag,0,sizeof(flag));
> 	for(i=0;i<n;i++)
> 	{
> 		if(g[p][i])
> 		{
> 			if(sg[i]==-1)
> 			{
> 				dfs(i);
> 				flag[sg[i]]=1;
> 			}
> 			else
> 			{
> 				flag[sg[i]]=1;
> 			}
> 		}
> 	}
> 	for(i=0;i<n;i++)
> 		if(flag[i]==0)
> 		{
> 			sg[p]=i;
> 			break;
> 		}
> }
> int main()
> {
> 	int i,j,temp,res;
> 	while(scanf("%d",&n)!=EOF)
> 	{
> 		memset(g,0,sizeof(g));
> 		memset(sg,0xff,sizeof(sg));
> 		for(i=0;i<n;i++)
> 		{
> 			scanf("%d",&num);
> 			for(j=0;j<num;j++)
> 			{
> 				scanf("%d",&temp);
> 				g[i][temp]=1;
> 			}
> 		}
> 		for(i=0;i<n;i++)
> 			if(sg[i]==-1)
> 				dfs(i);
> 		while(scanf("%d",&m),m!=0)
> 		{
> 			res=0;
> 			for(i=0;i<m;i++)
> 			{
> 				scanf("%d",&temp);
> 				res=res^sg[temp];
> 			}
> 			if(res==0)
> 				printf("LOSE\n");
> 			else
> 				printf("WIN\n");
> 		}
> 	}
> 	return 0;
> }
> 之后把flag数组改为在dfs函数里面定义,如下:
> void dfs(int p)
> {
> 	int i;
> 	bool flag[1001]={false};
> 结果AC了

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