pat-a1091. Acute Stroke (30)
来源:互联网 发布:淘宝卖家心酸 编辑:程序博客网 时间:2024/03/29 00:15
读题有点难。。。。注意维数对应即可
#include<cstdio>#include<queue>using namespace std;int mapx[1500][150][100];bool visit[1500][150][100]={0};int n,m,l;struct node{int x,y,z;node(int a=0,int b=0,int c=0):x(a),y(b),z(c){}};int dix[6]={0,0,0,0,1,-1};int diy[6]={0,0,1,-1,0,0};int diz[6]={1,-1,0,0,0,0};bool istrue(int x,int y,int z){return x>=0&&y>=0&&z>=0&&x<n&&y<m&&z<l;}int bfs(int x,int y,int z){int su=1;visit[x][y][z]=1;queue<node> q;q.push(node(x,y,z));while(!q.empty()){node t=q.front();q.pop();for(int i=0;i<6;++i){int nx=t.x+dix[i];int ny=t.y+diy[i];int nz=t.z+diz[i];if(istrue(nx,ny,nz)&&visit[nx][ny][nz]==0&&mapx[nx][ny][nz]==1){ q.push(node(nx,ny,nz));visit[nx][ny][nz]=1;su++;}}}return su;}int main(){int t,sum=0;scanf("%d%d%d%d",&n,&m,&l,&t);for(int i=0;i<l;++i) for(int j=0;j<n;++j) for(int z=0;z<m;++z) scanf("%d",&mapx[j][z][i]);for(int i=0;i<l;++i) for(int j=0;j<n;++j) for(int z=0;z<m;++z){ if(visit[j][z][i]==0&&mapx[j][z][i]==1){ int ans=bfs(j,z,i); if(ans>=t) sum+=ans; } }printf("%d\n",sum);return 0;}
One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI slice, your job is to calculate the volume of the stroke core.
Input Specification:
Each input file contains one test case. For each case, the first line contains 4 positive integers: M, N, L and T, where M and N are the sizes of each slice (i.e. pixels of a slice are in an M by N matrix, and the maximum resolution is 1286 by 128); L (<=60) is the number of slices of a brain; and T is the integer threshold (i.e. if the volume of a connected core is less than T, then that core must not be counted).
Then L slices are given. Each slice is represented by an M by N matrix of 0's and 1's, where 1 represents a pixel of stroke, and 0 means normal. Since the thickness of a slice is a constant, we only have to count the number of 1's to obtain the volume. However, there might be several separated core regions in a brain, and only those with their volumes no less than T are counted. Two pixels are "connected" and hence belong to the same region if they share a common side, as shown by Figure 1 where all the 6 red pixels are connected to the blue one.
Figure 1
Output Specification:
For each case, output in a line the total volume of the stroke core.
Sample Input:3 4 5 21 1 1 11 1 1 11 1 1 10 0 1 10 0 1 10 0 1 11 0 1 10 1 0 00 0 0 01 0 1 10 0 0 00 0 0 00 0 0 10 0 0 11 0 0 0Sample Output:
26
- 【PAT】A1091. Acute Stroke (30)
- PAT A1091. Acute Stroke (30)
- pat-a1091. Acute Stroke (30)
- A1091. Acute Stroke (30)
- PAT Acute Stroke (30)
- pat- Acute Stroke (30)
- PAT 1091. Acute Stroke (30)
- PAT 1091. Acute Stroke (30)
- 【PAT】1091. Acute Stroke (30)
- PAT 1091. Acute Stroke (30)
- PAT A 1091. Acute Stroke (30)
- PAT(Advance) 1091. Acute Stroke (30)
- PAT 1091. Acute Stroke (30)(孤岛问题)
- PAT(A) - 1091. Acute Stroke (30)
- PAT--1091. Acute Stroke (30)(三维bfs)
- 1091. Acute Stroke (30) PAT甲级
- PAT-A-1091. Acute Stroke (30)
- Pat(A) 1091. Acute Stroke (30)
- linux几个常用命令总结
- Python_01
- Android 简单的MVP实例
- hduoj 2019数列有序
- Alluxio增强Spark和MapReduce存储能力
- pat-a1091. Acute Stroke (30)
- 获取Android设备唯一标识码
- UWP 入门笔记之学习资源
- poj 1850 Code(组合计数)
- 关于Ubuntu系统无法搜索到wifi信号的解决办法
- String为什么不可变
- thinkphp模板标签用法大全
- 夜间模式的实现
- Collection接口API