题目链接:
代码如下:
#include <bits/stdc++.h>
using namespace std;
map<string,int> maps; //存储对应字符串需要的移位次数
bool Satisfy(string str){ //判断是否满足解密条件
if(str.find("2012")!=string::npos){ //判断str中是否有“2012”这个串
return true;
}else{
return false;
}
}
string exchange(string str,int i,int j){ //交换字符串str两个位置的元素
string strTmp=str;
char c=strTmp[i];
strTmp[i]=strTmp[j];
strTmp[j]=c;
return strTmp;
}
int BFS(string str){
queue<s