循环次数较少,可以直接广搜 ">using namespace std; string st,ed; unordered_map<string, int> d;//记录每一个状态所需的交换次数 int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; void bfs() { queue<string> q; q.push(st); while(q.size()) { string t=q.front();//从队列中取出一种状态 q.pop(); if(t==ed){cout<<d[ed];return;}//...