pat1091 Acute Stroke
来源:互联网 发布:windows自带图片编辑器 编辑:程序博客网 时间:2024/06/03 13:14
#include<cstdio>#include<iostream>#include<algorithm>#include<vector>#include<queue>#include<string>#include<cstring>#include<cmath>#include<map>#define ll long longusing namespace std;int n,m,l;bool a[70][1300][130],vis[70][1300][130];int dir[6][3] = {{0,0,1},{0,0,-1},{0,1,0},{0,-1,0},{1,0,0},{-1,0,0}};struct node{int x,y,z;node(int _x,int _y,int _z){x = _x;y = _y;z = _z;}};queue<node*>q;int bfs(int x,int y,int z){int ret = 0;vis[x][y][z] = true;node *tmp = new node(x,y,z);q.push(tmp);while(!q.empty()){tmp = q.front();ret++;q.pop();for(int i = 0;i<6;i++) { int nx = tmp->x+dir[i][0]; int ny = tmp->y+dir[i][1]; int nz = tmp->z+dir[i][2]; if(nx<0||nx>=l||ny<0||ny>=n||nz<0||nz>=m)continue; if(!vis[nx][ny][nz]&&a[nx][ny][nz]) { vis[nx][ny][nz] = 1; q.push(new node(nx,ny,nz)); }}}return ret;}int main(){int t,i,j,k,ans;while(scanf("%d%d%d%d",&n,&m,&l,&t)!=EOF){ans = 0;memset(vis,false,sizeof(vis));for(k = 0;k<l;k++)for(i = 0;i<n;i++)for(j = 0;j<m;j++)scanf("%d",&a[k][i][j]);for(k = 0;k<l;k++)for(i = 0;i<n;i++)for(j = 0;j<m;j++){int num =0;if(!vis[k][i][j]&&a[k][i][j])num = bfs(k,i,j);if(num>=t)ans+=num;}printf("%d\n",ans);} return 0;}
0 0
- pat1091 Acute Stroke
- PAT1091. Acute Stroke (30)
- Acute Stroke
- 1091. Acute Stroke
- PAT 1091. Acute Stroke
- 1091. Acute Stroke (30)
- 1091. Acute Stroke (30)
- 1091.Acute Stroke
- 1091. Acute Stroke (30)
- 1091. Acute Stroke (30)
- 1091. Acute Stroke (30)
- 1091. Acute Stroke (30)
- 1091. Acute Stroke (30)
- 1091. Acute Stroke (30)
- 1091. Acute Stroke (30)
- 1091. Acute Stroke (30)
- PAT1004-Acute Stroke (30)
- 1091. Acute Stroke(30)
- tomcat管理后台的jsp(webshell)
- Java异常详解
- BZOJ 3884 上帝与集合的正确用法
- C++程序设计必知:类的静态成员
- 2015
- pat1091 Acute Stroke
- poj2385 dp
- axTOCControl.HitTest方法
- IOS键盘通知中心方法
- select之二
- hdu 5171 GTY's birthday gift (构造矩阵)
- Ubuntu添加PPA源
- 11.网银大盗木马技术分析
- Objective-C基本语法概述