自我感觉没错
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Pos{
int x,cost;
Pos(int ax = 0, int acost = 0) {
x=ax,cost=acost;
}
};
int n,a,b,t[12912345];
bool vis[100001205];
void bfs() {
queue<Pos>q;
q.push(Pos(a,0));
while(!q.empty()) {
Pos now=q.front();
q.pop();
int x = now.x, cost = now.cost;
if(x==b){
cout<<cost<<endl;
return;
}
if(x<1){
continue;
}
if(vis[x]==1){
continue;
}
vis[x]=1;
q.push(Pos(x+1,cost+1));
q.push(Pos(x-1,cost+1));
q.push(Pos(x+10,cost+1));
q.push(Pos(x-10,cost+1));
q.push(Pos(x-5,cost+1));
q.push(Pos(x+5,cost+1));
}
}
int main() {
cin>>a>>b;
bfs();
return 0;
}