文章

82

粉丝

343

获赞

27

访问

661.0k

头像
注意有多个出口
P1563 天津大学/南开大学2019年机试题
发布于2021年2月2日 15:24
阅读数 8.7k

#include<iostream>
#include<string.h>
#include<queue>
using namespace std;

struct node{
    int x,y;
    int step;
};
queue  <node> q;
int map[105][105];
int out[105][105];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int h,w;
int sx,sy,ex,ey;
void bfs(){
    q.push(node{sx,sy,0});
    while(!q.empty()){
        node t=q.front();
        q.pop();
        if(out[t.x][t.y]==1){
            cout<<t.step<<endl;
            return ;
        }
        for(int i=0;i<4;i++){
            int xx=t.x+dx[i];
            int yy=t.y+dy[i];
&nb...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发