#include
using namespace std;
const int N=1e6+5;
char dict[10][6][4]= { //本题的状态与每个组合技能的顺序有关
{"QQQ","QQQ","QQQ","QQQ","QQQ","QQQ"}, //直接枚举每个组合技能的顺序
{"QQW","QWQ","QQW","QWQ","WQQ","WQQ"},
{"QQE","QEQ","QQE","QEQ","EQQ","EQQ"},
{"WWW","WWW","WWW","WWW","WWW","WWW"},
{"QWW","QWW","WQW","WWQ","WQW","WWQ"},
{"WWE","WEW","WWE","WEW","EWW","EWW"},
{"EEE","EEE","EEE","EEE","EEE","EEE"},
{"QEE","QEE","EQE","EEQ","EQE","EEQ"},
{"WEE","WEE","EWE","EEW","EWE","EEW"},
{"QWE","QEW","WQE","WEQ","EQW","EWQ"}
};
int dp[N][10];
int cal(int a,int b,int x,int y) { //a表示前一个状态(第a个状态) a x表示第a个组合技第x种顺序
//计算前后两种状态组合技需要多按几次按键
if(dict[a][x][0]==dict[b][y][0] && dict[a][x][1] == dict[b][y][1] && dict[a][x][2]==dict[b][y][2])
return 0;
if(dict[a][x][1]==dict[b][y][0] && dict[a][x][2] == dict[b][y][1])
return 1;
if(dict[a][x][2]== dict[b][y][0])
return 2;
return 3;
}
mapmp;
int st[N];
int main() {
string s;
mp['Y']=0;
mp['V']=1;
mp['G']=2;
mp['C']=3;
mp['X']=4;
mp['Z']=5;
mp['T']=6;
mp['F']=7;
mp['D']=8;
mp['B']=9;
while(cin>>s) {
int ans=2147483647;
int cc=0;
for(int i=0; i=1&&s[i]==s[i-1])
continue;
else {
// t+=s[i];
st[cc]=mp[s[i]];
cc++;
}
}
// cout<
参考了这位大佬的博客:https://blog.csdn.net/qq_43461168/article/details/101210999