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

code2:RE 请观察与code1的区别(只有两处)

Posted by fzfzfz at 2015-01-12 11:49:40 on Problem 2960
In Reply To: 这神奇的机制,我也是醉了。下附三份代码,请君感受神奇的RE判定 Posted by:fzfzfz at 2015-01-12 11:47:39
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 305
#define M 30100
using namespace std;
int S,s[N];
int sg[M];
int SG(int x)
{
	int i;
	if(sg[x]+1)return sg[x];
	bool vis[M<<1]={0};
	for(i=1;i<=S&&s[i]<=x;i++)vis[SG(x-s[i])]=true;
	for(i=0;vis[i];i++);
	return sg[x]=i;
}
int n,m;
int main()
{
//	freopen("test.in","r",stdin);
	int i,k,g;
	while(scanf("%d",&S),S)// 数据组数A
	{
		for(i=1;i<=S;i++)scanf("%d",&s[i]); 
		sort(s+1,s+S+1);
			// s : 每次可以取的石子数量集合
		memset(sg,-1,sizeof(sg)),sg[0]=0;
		for(scanf("%d",&g);g--;) // 数据组数B
		{
			for(k=0,scanf("%d",&n);n--;) // n堆石子
			{
				scanf("%d",&m); // 该堆石子的个数
				k^=SG(m);
			}
			if(k)putchar('W');
			else putchar('L');
		}
		 puts("");
	}
	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