题目大意:

输入n个标准字符串(10,000),然后给你m个字符串(50),每个字符串都不长于15个字符问你分别判断这m个字符串是不是可以通过加一个字符,减一个字符或者换一个字符来变成给出的n的标准字符串,或者这个字符串本来就是标准字符串。(如果这个字符串的标准字符串)有多个,那么全部输出(按照其对应的标准字符串出现的顺序)。 


时间复杂度:10000*50*15=7,500,000;按理说,应该是可以过的。所以就不打算根据字符串长度排序了


#include<iostream> 
#include<string.h>
#include<math.h>
#include<stdio.h>
#define N 10500
#define M 60
using namespace std;
int n=0;
int m=0;
char b[N][20]={0};//标准字符串
char a[M][20]={0};//要判断的字符串

void input()
{
	while(1)
	{
		scanf("%s",b[n]);
		if(b[n][0]=='#')break;
		n++;
	}
	while(1)
	{
		scanf("%s",a[m]);
		if(a[m][0]=='#')break;
		m++;
	}
}

void ceshi1()
{
	for(int i=0;i<n;i++)
	{
		cout<<b[i]<<endl;
	}
	for(int i=0;i<m;i++)
	{
		cout<<a[i]<<endl;
	}
}

int check(int x,int y)//比较,判断字符串a[x],和标准字符串b[y]。完全相同1,可以改正2,不能改0 
{
	int i=0;
	int j=0;
	if(strlen(a[x])==strlen(b[y]))//完全相同或者替换 
	{
		int s=0;
		while(i<strlen(a[x]))
		{
			if(a[x][i]!=b[y][j])s++;
			i++;j++;
		}
		if(s==0)return 1;
		if(s==1)return 2;
		return 0;
	}
	if(strlen(a[x])==strlen(b[y])+1)//删除 
	{
		int s=0;
		while(i<strlen(a[x]))
		{
			if(a[x][i]!=b[y][j])
			{
				i++;
				s++;
				continue;
			}
			i++;j++;
		}
		if(s==1)return 2;
		return 0;
	}
	if(strlen(a[x])==strlen(b[y])-1)//添加 
	{
		int s=0;
		while(j<strlen(b[y]))
		{
			if(a[x][i]!=b[y][j])
			{
				j++;
				s++;
				continue;
			}
			i++;j++;
		}
		if(s==1)return 2;
		return 0;
	}
	return 0;
}

void output(int x,int i,int j)
{
	if(x==2)cout<<" "<<b[j];
}

int main()
{
	input();
	//ceshi1();
	for(int i=0;i<m;i++)//反别判断每个字符串 
	{
		cout<<a[i];
		bool flag=0;
		for(int j=0;j<n;j++)
		{
			if(check(i,j)==1)
			{
				flag=1;
				break;
			}
		}
		if(flag==1)
		{
			cout<<" is correct"<<endl;
			continue;
		}
		cout<<":";
		for(int j=0;j<n;j++)
		{
			output(check(i,j),i,j);
		}
		cout<<endl;
	}
	
}