文章

82

粉丝

343

获赞

27

访问

662.3k

头像
注意充满的条件
P1126
发布于2021年2月2日 18:22
阅读数 8.3k

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

struct node{
    int x,y;
    int step;
};

queue <node> q;
int n,m,t;
int sx,sy;
char map[35][35];
int vis[35][35];

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};

int flag;
void bfs(){
    flag=0;
    map[sx][sy]='#';
    q.push(node{sx,sy,0});
    while(!q.empty()){
        node tt=q.front();    q.pop();
        if(tt.step==t){//提前充满的队列里不会有step==t的元素  
            flag=1;//充不满和刚好充满的队列里  刚扩展完t-1时候  那么第t时刻的扩散完成  提前充满的在充满后队列不会扩展进新元素
            return ;
        }    
        
     ...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发