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

233333

Posted by FUZEmount at 2017-07-18 15:34:48 on Problem 1318
#include"iostream"
#include"string.h"
#include"cstdio"
#include"string"
using namespace std;
string c0[101],c[101];
int num0[101][30],num[101][30],n0,n,fn,dz[101][101];
void bj(int s)
{
	int flag=0;
	int k=0;
	memset(dz,-1,sizeof(dz));
	for(int i=0;i<n0;i++)
	{
		flag=0;
		for(int j=1;j<=26;j++)
		{
			if(num0[i][j]!=num[s][j])
			{
				flag=1;
				break;
			}
		}
		if(flag==0)
		{
			dz[s][k]=i;
			k++;
		}
	}
}
int main ()
{
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	
	while(cin>>c0[0])
	{
		for(int i=1;;i++)
		{
			cin>>c0[i];
			if(c0[i]=="XXXXXX")
			{
				n0=i;
				break;
			}			
		}
		string t;
		int f;
		for(int i=0;i<n0-2;i++)
		{
			f=0;
			for(int j=0;j<n0-1;j++)
			{
				if(c0[j]>c0[j+1])
				{
					t=c0[j];
					c0[j]=c0[j+1];
					c0[j+1]=t;
					f=1;
				}
			}
			if(f==0)break;
		}
		for(int i=0;;i++)
		{
			cin>>c[i];
			if(c[i]=="XXXXXX")
			{
				n=i;
				break;
			}
		}
		for(int i=0;i<n;i++)
	    {
		   int len=c[i].length();
		   for(int j=0;j<len;j++)
		   {
			num[i][c[i][j]-96]++;
		   }
	    }
	    for(int i=0;i<n0;i++)
	    {
		   int len=c0[i].length();
		   for(int j=0;j<len;j++)
		   {
			num0[i][c0[i][j]-96]++;
		   }
	    }
	    for(int i=0;i<n;i++)
	    {
	    		bj(i);
	    		for(int j=0;dz[i][j]!=-1;j++)
	    		{
				    cout<<c0[dz[i][j]]<<endl;
	    		}
	    		if(dz[i][0]==-1)
	    		   cout<<"NOT A VALID WORD"<<endl; 	    		   	    
	    	cout<<"******"<<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