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

我的为什么WA啊?

Posted by thugggg at 2007-03-26 13:07:34 on Problem 2192
#include <iostream>
#include <string>
using namespace std;
int n,flag;
char A[202],B[202],C[10000];
int result,a,b,c,k;
int re[1001],s[202][100000],pos[202][402],total[402];
int y[402],X[202],z[202];
//S1,...,Sa;
//total[1]*...*total[a];
int judge()
{
	int i,k,tr;
	//给定解空间X后,判断是否对
	for (i=0;i<c;i++) y[i]=0;
	for (i=0;i<a;i++) y[X[i]]=1;
	k=-1;
	for (i=0;i<c;i++)
	{
		if (y[i]==0)
		{
			k+=1;
			z[k]=i;
		}
	}
	tr=1;
	for (i=0;i<b;i++)
		if (B[i]!=C[z[i]])
		{
			tr=0;
			break;
		}
	return tr;
}
void input()
{
       cin>>A;
	   cin>>B;
	   cin>>C;
       result=0;
       a=strlen(A);
	   b=strlen(B);
	   c=strlen(C);
}
void initial()
{
	int i,j,k;
	for (i=0;i<a;i++)
		   {
			   k=0;
		   for (j=0;j<c;j++)
		   {
			   if (A[i]==C[j]) 
			   {
				   s[i][j]=1;
				   k+=1;
				   pos[i][k]=j;

			   }
			   else s[i][j]=0;
		   }
		   total[i]=k;
		   }
}
int advance(int k)
{
	int i;
	for (i=1;i<=total[i];i++)
	{
		if (k==0 || (k>0 && pos[k][i]>X[k-1]))
		{
		X[k]=pos[k][i];
		if (k==a-1 && judge()==1)
		{
			return 1;
		}
		if (k<a-1) return advance(k+1);
		}
	}
	return 0;
}
void main()
{
	int i;
	cin>>n;
	for (i=1;i<=n;i++)
	{
	  
	      input();
	      initial();
	      flag=false;
		  re[i]=advance(0);
		  
		   
	}
	for (i=1;i<=n;i++)
		if (re[i]==1) printf("Data set %d: yes\n",i);
		else printf("Data set %d: no\n",i);
      
}

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