https://pintia.cn/problem-sets/994805342720868352/problems/994805375457411072
很常见的题,就是求每一个连通块的大小。

#include<bits/stdc++.h>
using namespace std;
const int N=150;
const int M=2000;
const int L=65;
int f[L][M][N],n,m,l,t,ans;
bool st[L][M][N];
struct node{int x,y,z;};
void bfs(int x,int y,int z)
{int dx[6]={-1,0,0,1,0,0};int dy[6]={0,-1,1,0,0,0};int dz[6]={0,0,0,0,1,-1};int cnt=1;st[z][x][y]=1;queue<node>q; q.push({x,y,z});while(q.size()){auto t=q.front(); q.pop();x=t.x,y=t.y,z=t.z;for(int i=0;i<6;i++){int tempx=x+dx[i];int tempy=y+dy[i];int tempz=z+dz[i];if(tempx<0||tempx>=m||tempy<0||tempy>=n||tempz<0||tempz>=l) continue;if(st[tempz][tempx][tempy]) continue;if(!f[tempz][tempx][tempy]) continue;q.push({tempx,tempy,tempz});st[tempz][tempx][tempy]=1,cnt++;}}if(cnt>=t) ans+=cnt;
}
int main(void)
{cin>>m>>n>>l>>t;for(int i=0;i<l;i++)for(int j=0;j<m;j++)for(int z=0;z<n;z++)cin>>f[i][j][z];for(int i=0;i<l;i++)for(int j=0;j<m;j++)for(int z=0;z<n;z++)if(!st[i][j][z]&&f[i][j][z]) bfs(j,z,i);cout<<ans;return 0;
}

1091 Acute Stroke (30 分)【难度: 一般 / bfs】相关推荐

  1. 【PTA-A】1091 Acute Stroke (30 分)(BFS、队列)

    One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the re ...

  2. 【PAT甲级题解】1091 Acute Stroke (30分) BFS

    本题考BFS应用,题目大意是给出一个三维0,1矩阵,你需要对任意一个元素的上下左右前后进行判断枚举,如果当前元素为1且满足要求,则入队,当前枚举结束后如果该'1'矩阵不小于一个'l'代表的阈值则返回其 ...

  3. 【PAT】1091 Acute Stroke (30 分)

    三维搜索,按照6个邻接理论,总会有重合的部分区域, 因此根据搜索顺序,先访问到的就是一个区域的[不能较真] #include <bits/stdc++.h> using namespace ...

  4. 1091 Acute Stroke (30)(30 分)

    One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the re ...

  5. 1091. Acute Stroke (30)

    题目如下: One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given ...

  6. 1091. Acute Stroke (30)-PAT甲级真题(广度优先搜索)

    One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the re ...

  7. PAT甲级 1091 Acute Stroke(30) (Flood Fill)

    题目 One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the ...

  8. PAT甲题题解-1091. Acute Stroke (30)-BFS

    题意:给定三维数组,0表示正常,1表示有肿瘤块,肿瘤块的区域>=t才算是肿瘤,求所有肿瘤块的体积和 这道题一开始就想到了dfs或者bfs,但当时看数据量挺大的,以为会导致栈溢出,所以并没有立刻写 ...

  9. pat1091. Acute Stroke (30)

    1091. Acute Stroke (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue One impo ...

最新文章

  1. 批处理下的 cd 与 cd /d 命令
  2. 常考数据结构与算法:求二叉树的层序遍历
  3. 修改bootstrap modal模态框的宽度
  4. 夏普linux掌上电脑,夏普展示Ubuntu系统NetWalker PC-Z1[图文]
  5. 买到同类票的概率(洛谷P2719题题解,Java语言描述)
  6. 信息学奥赛一本通 2047:【例5.16】过滤空格 | OpenJudge NOI 1.7 23:过滤多余的空格
  7. easyui源码翻译1.32--panel(面板)
  8. 常用的模型评估指标(转)
  9. linux下开通ssh
  10. SUMO交通流仿真实战
  11. Vbs 脚本编程简明教程之一
  12. 常见的监控项目组网方案技术系统图,一文了解清楚!
  13. BRCA1、BRCA2基因突变的检测方法与流程
  14. 《如何学商学》及听课感想
  15. 易语言服务器客户端网络验证,超强网络验证系统附远程服务支持库
  16. C#调用FluentFTP将文件批量上传到ftp服务器
  17. 美国航空发动机发展经验,给中国的启示!
  18. 服务器多个cpu的作用,服务器多核CPU是什么?多核CPU有什么用?
  19. Axure RP9 轮播图交互
  20. R星安装不完全无法载入social club(错误码:1)解决办法

热门文章

  1. MAT之SVM/BP:SVR(better)和BP两种方法比较且实现建筑物钢筋混凝土抗压强度预测
  2. BootStrap Table - JS事件绑定
  3. http和https的一种能力?
  4. concurrent (二)AQS
  5. php7+apache2.4配置
  6. [R]R语言中的%%和%.%
  7. 给大忙人看的Java核心技术笔记(8、Stream)
  8. Thread.setDefaultUncaughtExceptionHandler作用
  9. ASP编程中的Microsoft JScript 编译错误 错误 '800a03ec'缺少;的解决方法.
  10. JAVA教程 第六讲 Java的线程和Java Applet(二)