文章
40
粉丝
512
获赞
13
访问
372.9k
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
struct status{
int n,t;
status(int x,int y):n(x),t(y){}
};
bool visit[201];
int N,A,B;
int arr[201];
int BFS(int a,int b){
queue<status> mq;
mq.push(status(a,0));
visit[a]=true;
while(!mq.empty()){
status current = mq.front();
mq.pop();
if(current.n==b){
return current.t;
}
for(int i=0;i<2;i++){
status next(current.n,current.t+1);
if(i==0){
next.n -= arr[next.n];
}else{
&nbs...
登录后发布评论
建议用代码插件,高亮语法显示,更容易阅读