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:哪位牛人帮忙给组BT的数据?

Posted by yipingan at 2012-08-06 20:27:13 on Problem 2475
In Reply To:哪位牛人帮忙给组BT的数据? Posted by:a024014 at 2007-04-14 14:13:08
21 
,,,
{{}},{,}}
{{{,},{,},,}}
{,,,}
,
{
}
,,
{{
}}
}{
{,,}
{,}
{{}
{}}
{}
{{}}
{}
{{}}
{{}},{,}}
{,,}

Answer:
Word #1: No Set
Word #2: Set
Word #3: Set
Word #4: Set
Word #5: No Set
Word #6: No Set
Word #7: No Set
Word #8: No Set
Word #9: No Set
Word #10: No Set
Word #11: No Set
Word #12: No Set
Word #13: Set
Word #14: Set
Word #15: Set
Word #16: Set
Word #17: Set
Word #18: Set
Word #19: Set
Word #20: Set
Word #21: No Set
> #include <stdio.h>
> #include <string.h>
> bool judge(char *str,int start,int end)
> {
> 	int i,j,pos,px;
> 	char s[256];
> 	bool flag=false;
> 	if(str[start]!='{'||str[end-1]!='}') return false;
> 	if(end-start==2||end-start==3) return true;
> 	pos=start+1;
> 	while(1)
> 	{
> 		if(pos>=end-1)
> 			break;
> 		if(str[pos]=='{')
> 		{
> 			for(i=pos+1;i<end-1;i++)
> 			{
> 				if(str[i]=='}')
> 				{
> 					if(i==end-2&&judge(str,pos,i+1))
> 						return true;
> 					else if(i!=end-2&&str[i+1]==',')
> 						if(judge(str,pos,i+1))
> 						{
> 							s[0]='{',px=1;
> 							for(j=i+2;j<end-1;j++)
> 								s[px++]=str[j];
> 							s[px]='}';
> 							s[px+1]='\0';
> 							if(judge(s,0,strlen(s)))
> 								return true;
> 						}
> 				}
> 			}
> 		}
> 		flag=false;
> 		if(pos+1>=end-1)
> 			break;
> 		if(str[pos+1]!=',') return false;
> 		else flag=true;
> 		pos=pos+2;
> 	}
> 	if(flag) return false;
> 	return true;
> }
> int main()
> {
> 	int t,c=0;
> 	char str[256];
> 	//freopen("d:\\1.txt","r",stdin);
> 	scanf("%d",&t);
> 	while(t--)
> 	{
> 		scanf("%s",str);
> 		printf("Word #%d: ",++c);
> 		judge(str,0,strlen(str))?printf("Set\n"):printf("No Set\n");
> 	}
> 	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