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

进来看看 或许能共同进步~

Posted by highspeed at 2010-07-26 20:35:05 on Problem 2425
高手看看哪写错了。。。实在没办法了才贴代码的。。。
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;

int N,adge,m;
vector<int>G[1001];
int SG[1010];
int sg(int k)
{
	if(G[k].size()==0)return SG[k]=0;
	if(SG[k]!=-1)return SG[k];
	int len=G[k].size();
	bool flag[1010];
	memset(flag,false,sizeof(flag));
	for(int i=0;i<len;i++)
		flag[sg(G[k][i])]=true;
	for(int i=0;i<len;i++)
		if(!flag[i])
			return SG[k]=i;
}
int main()
{
	
	while(cin>>N)
	{
		for(int i=0;i<N;i++)
		{
			scanf("%d",&m);
		    for(int j=0;j<m;j++)
			{
				scanf("%d",&adge);
				G[i].push_back(adge);
		    }
		}
		int q;
		memset(SG,-1,sizeof(SG));
		while(scanf("%d",&q)!=EOF&&q)
		{
			int ans,temp;
			scanf("%d",&temp);
			ans=sg(temp);
			for(int i=1;i<q;i++)
			{
				scanf("%d",&temp);
				ans^=temp;
			}
			if(!ans)printf("LOSE\n");
			else printf("WIN\n");
		}
		for(int i=0;i<1001;i++)G[i].clear();
	}
	return 0;
}

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