BFS

登录以参加训练计划

课件

struct node{
	int x,y;
};
queue <node> q;
void bfs(){
  node a={1,1}; 
  vis[1][1]=1;
  q.push(a);
  while( q.empty()!=1 ){
         node f=q.front();
        if(mp[f.x][f.y]== ){ 
	       cout<<"YES";  
		   return;
    	}  
    for(int i=0; i<4; i++){
             int nx = f.x + dx[i], ny = f.y + dy[i];
             if (nx>0&& nx<=n&& ny>0&&ny<=m&&mp[nx][ny]!=0&&vis[nx][ny]==0) {
             vis[nx][ny]=1; 
             node r={nx,ny}; 
             q.push(r); 
            }
        }
        q.pop( );
       }
    cout<<"NO";}

章节 1. 课上讲解

开放

题目 尝试 AC 难度
7194   【基础】迷宫出口 41 10 7
8886   【入门】黑色联通块 33 10 7
8568   【入门】快乐的马里奥 31 9 7
 
参加人数
12
创建人