这里是源代码
#include<bits/stdc++.h>
using namespace std;
#define PII pair<int,int>
inline int read(){
int sum=0,h=1;
char ch=getchar();
while(!isdigit(ch)){if(ch=='-') h=-1;ch=getchar();}
while(isdigit(ch)){sum=sum*10+ch-'0';ch=getchar();}
return sum*h;
}
int dir[2]={1,-1};
int n,x,y;
queue<PII> q;
inline void bfs(){
while(!q.empty()){
PII top=q.front();q.pop();
int ax=top.first,cnt=top.second;
if(ax==y){
cout<<cnt<<endl;
return;
}
for(register int i=0;i<=2;++i){
if(i==2){
int bx=ax*2;
q.push({bx,cnt+1});
break;
}
int bx=ax+dir[i];
if(bx<=0) continue;
q.push({bx,cnt+1});
}
}
return;
}
int main(){
n=read();
for(register int i=0;i<n;++i){
x=read(),y=read();
q.push({x,0});
bfs();
}
return 0;
}
求助大佬,指明原因。