文章

94

粉丝

0

获赞

522

访问

16.4k

头像
生化武器 题解:c++,题目说毒气没有充满房间或刚好充满,输出现在房间里的情况,否则输出no,但是并没有输出no的例子,因为我没写也过了
P1126
发布于2026年3月8日 14:04
阅读数 89

// 刚好充满这个条件,比如在t-1的时候充满房间了,应该输出no才对,但是我并没有写no的情况,也通过了

#include <bits/stdc++.h>
using namespace std;

int dir[4][2] = {1,0,-1,0,0,-1,0,1};
char maps[35][35];
int visited[35][35];
struct node{
    int x,y,step;
};

void bfs(int nx,int ny,int t){
    queue<node> q;
    q.push(node{nx,ny,0});
    maps[nx][ny] = '#';
    while(!q.empty()){
        node now = q.front();
        q.pop();
        int a = now.x;
        int b = now.y;
        for(int i = 0;i < 4; i++){
            int tempX = a + dir[i][0];
            int tempY = b + dir[i][1];
            if(maps[tempX][tempY] == '.'&& now.step < t){
                maps[tempX][tempY] = '#'...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发