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 sweetsc at 2010-01-31 22:12:00 on Problem 1816
RT……

p是pattern,now是输入字符串,1300MS通过……
bool go(char now[],char p[])
{
	if (p[0]=='*' && p[1]==0) return 1;
	if (now[0]==0 || p[0]==0)
	{
		if (now[0]==0 && p[0]==0) return 1;
		return 0;
	}
	if (p[0]=='?'|| p[0]==now[0])
		return go(now+1,p+1);
	if (p[0]=='*')
	{
		for (char *i=now;;i++)
		{
			if (go(i,p+1))
				return 1;
			if (*i==0) return 0;
		}
		return 0;
	}
	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