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

wh WA????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????/

Posted by BJ051155 at 2007-05-06 21:09:18 on Problem 2192
#include <iostream.h>
#include <string.h>


void main()
{
	char a[201],b[201],c[401];
	int n,i,j,k,m,stacki[201],stackj[201],top,num1[26],num2[26],num3[26];
	cin>>n;
	for(m=1;m<=n;m++)
	{
		cin>>a>>b>>c;
		for(i=0;i<26;i++)
			num1[i]=num2[i]=num3[i]=0;
		for(i=0;i<strlen(a);i++)
			num1[a[i]-'a']++;
		for(i=0;i<strlen(b);i++)
			num2[b[i]-'a']++;
		for(i=0;i<strlen(c);i++)
			num3[c[i]-'a']++;
		bool sign=1;
		for(i=0;i<26&&sign;i++)
			if(num1[i]+num2[i]!=num3[i])
				sign=0;
		if(sign==0)
		{
			cout<<"Data set "<<m<<": no"<<endl;
			continue;
		}
		top=k=i=j=0;
		while(k<strlen(c))
		{
			if(c[k]==a[i]&&c[k]!=b[j])
			{
				i++;
				k++;
				continue;
			}
			if(c[k]==b[j]&&c[k]!=a[i])
			{
				j++;
				k++;
				continue;
			}
			if(c[k]==b[j]&&c[k]==a[i])
			{
				stacki[top]=i;
				stackj[top++]=j;
				i++;
				k++;
				continue;
			}
			if(c[k]!=a[i]&&c[k]!=b[j])
			{
				if(top--)
				{
					i=stacki[top];
					j=stackj[top]+1;
					k=i+j;
					continue;
				}
				else
				{
					cout<<"Data set "<<m<<": no"<<endl;
					break;
				}
			}
		}
		if(k==strlen(c))
			cout<<"Data set "<<m<<": yes"<<endl;
		
	}
}

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