去掉注销输出的是11 没去掉输出的1111 ?
#include<bits/stdc++.h>
using namespace std;
const int inf=1e6+5;
const int e[7]={0,100000,10000,1000,100,10,1};
int st,ed;
bool vis[inf][7],flag;
struct node{
int num,step,arrow;
node(int _num,int _step,int _arrow):
num(_num),step(_step),arrow(_arrow){}
}u(0,0,0);
queue<node>q;
void go_right(){if(flag)return ;
node v=u; v.arrow++; v.step++;
if(vis[v.num][v.arrow])return ;
vis[v.num][v.arrow]=true;
q.push(v); return ;
}
void go_leftt(){if(flag)return ;
node v=u; v.arrow--; v.step++;
if(vis[v.num][v.arrow])return ;
vis[v.num][v.arrow]=true;
q.push(v); return ;
}
void upup(){if(flag)return ;
node v=u; v.step++;
v.num=v.num+e[v.arrow];
if(v.num==ed){cout<<v.step;flag=true;}
if(vis[v.num][v.arrow])return ;
vis[v.num][v.arrow]=true;
q.push(v); return ;
}
void down(){if(flag)return ;
node v=u; v.step++;
v.num=v.num-e[v.arrow];
if(v.num==ed){cout<<v.step;flag=true;}
if(vis[v.num][v.arrow])return ;
vis[v.num][v.arrow]=true;
q.push(v); return ;
}
void swap0(){if(flag)return ;
node v=u;v.step++;
int kl=v.num/e[1];
int kr=(v.num/e[v.arrow])%10;
v.num=v.num-kl*e[1]+kr*e[1]-kr*e[v.arrow]+kl*e[v.arrow];
if(v.num==ed){cout<<v.step;flag=true;}
if(vis[v.num][v.arrow])return ;
vis[v.num][v.arrow]=true;
q.push(v); return ;
}
void swap1(){if(flag)return ;
node v=u;v.step++;
int kl=v.num%10;
int kr=(v.num/e[v.arrow])%10;
v.num=v.num-kl+kr-kr*e[v.arrow]+kl*e[v.arrow];
if(v.num==ed){cout<<v.step;flag=true;}
if(vis[v.num][v.arrow])return ;
vis[v.num][v.arrow]=true;
q.push(v); return ;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin>>st>>ed;
if(st==ed){cout<<'0';return 0;}
node a(st,0,1);q.push(a);
while(!q.empty()){
u=q.front();q.pop();
vis[u.num][u.arrow]=1;
//cout<<u.num<<' '<<u.step<<'\n';
if(u.num==ed){cout<<u.step;return 0;}
if(u.arrow!=6)go_right(),swap1();
if(u.arrow!=1)go_leftt(),swap0();
int k=(u.num/e[u.arrow])%10;
if(k>0)down();
if(k<6)upup();
}
return 0;
}