求助
查看原帖
求助
352961
Ztemily楼主2021/7/22 10:09

能编译过去但运行会弹出奇怪的东西

Code:

#include<bits/stdc++.h>
using namespace std;
string a,b;
string aa[11],bb[11];
int tot;
int ans=2147483647;
inline void dfs(string s,int st)
{
	if(st>10) return;
	if(s==b)
	{
		ans=ans<st?ans:st;
		return;
	}
	
	for(register int i=1;i<=tot;i++)
	{
		if(s.find(aa[i])) 
		{
			string sss=s.replace(s.find(aa[i]),aa[i].length(),bb[i]);
			dfs(sss,st+1);
		}
	}
	return;
}
inline void work()
{
	cin>>a>>b;
	while(cin>>aa[tot++]>>bb[tot++]);
	dfs(a,1);
	if(ans<=10) cout<<ans;
	else puts("NO ANSWER!");
	return ;
}
int main(void)
{
	work();
	return 0;
}
2021/7/22 10:09
加载中...