1091 Acute Stroke (30 分)【难度: 一般 / bfs】
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】相关推荐
- 【PTA-A】1091 Acute Stroke (30 分)(BFS、队列)
One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the re ...
- 【PAT甲级题解】1091 Acute Stroke (30分) BFS
本题考BFS应用,题目大意是给出一个三维0,1矩阵,你需要对任意一个元素的上下左右前后进行判断枚举,如果当前元素为1且满足要求,则入队,当前枚举结束后如果该'1'矩阵不小于一个'l'代表的阈值则返回其 ...
- 【PAT】1091 Acute Stroke (30 分)
三维搜索,按照6个邻接理论,总会有重合的部分区域, 因此根据搜索顺序,先访问到的就是一个区域的[不能较真] #include <bits/stdc++.h> using namespace ...
- 1091 Acute Stroke (30)(30 分)
One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the re ...
- 1091. Acute Stroke (30)
题目如下: One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given ...
- 1091. Acute Stroke (30)-PAT甲级真题(广度优先搜索)
One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the re ...
- PAT甲级 1091 Acute Stroke(30) (Flood Fill)
题目 One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the ...
- PAT甲题题解-1091. Acute Stroke (30)-BFS
题意:给定三维数组,0表示正常,1表示有肿瘤块,肿瘤块的区域>=t才算是肿瘤,求所有肿瘤块的体积和 这道题一开始就想到了dfs或者bfs,但当时看数据量挺大的,以为会导致栈溢出,所以并没有立刻写 ...
- pat1091. Acute Stroke (30)
1091. Acute Stroke (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue One impo ...
最新文章
- 批处理下的 cd 与 cd /d 命令
- 常考数据结构与算法:求二叉树的层序遍历
- 修改bootstrap modal模态框的宽度
- 夏普linux掌上电脑,夏普展示Ubuntu系统NetWalker PC-Z1[图文]
- 买到同类票的概率(洛谷P2719题题解,Java语言描述)
- 信息学奥赛一本通 2047:【例5.16】过滤空格 | OpenJudge NOI 1.7 23:过滤多余的空格
- easyui源码翻译1.32--panel(面板)
- 常用的模型评估指标(转)
- linux下开通ssh
- SUMO交通流仿真实战
- Vbs 脚本编程简明教程之一
- 常见的监控项目组网方案技术系统图,一文了解清楚!
- BRCA1、BRCA2基因突变的检测方法与流程
- 《如何学商学》及听课感想
- 易语言服务器客户端网络验证,超强网络验证系统附远程服务支持库
- C#调用FluentFTP将文件批量上传到ftp服务器
- 美国航空发动机发展经验,给中国的启示!
- 服务器多个cpu的作用,服务器多核CPU是什么?多核CPU有什么用?
- Axure RP9 轮播图交互
- R星安装不完全无法载入social club(错误码:1)解决办法
热门文章
- MAT之SVM/BP:SVR(better)和BP两种方法比较且实现建筑物钢筋混凝土抗压强度预测
- BootStrap Table - JS事件绑定
- http和https的一种能力?
- concurrent (二)AQS
- php7+apache2.4配置
- [R]R语言中的%%和%.%
- 给大忙人看的Java核心技术笔记(8、Stream)
- Thread.setDefaultUncaughtExceptionHandler作用
- ASP编程中的Microsoft JScript 编译错误 错误 '800a03ec'缺少;的解决方法.
- JAVA教程 第六讲 Java的线程和Java Applet(二)