PAT A1091 Acute Stroke
对于坐标平面的bfs模板题~
#include<bits/stdc++.h>
using namespace std;
const int maxn=;
bool visit[][][]={false};
int adj[][][];
int n,m,l,K;
int X[]={,,,-,,};
int Y[]={,,,,-,};
int Z[]={,,,,,-};
struct node {
int x,y,z;
};
bool judge (int x,int y,int z) {
if (x>=n||x<||y>=m||y<||z>=l||z<)
return false;
if (adj[x][y][z]==) return false;
if (visit[x][y][z]==true) return false;
return true;
}
int bfs (int x,int y,int z) {
queue<node> q;
q.push({x,y,z});
int cnt=;
visit[x][y][z]=true;
while (!q.empty()) {
node now=q.front();
q.pop();
cnt++;
for (int i=;i<;i++) {
int tx=now.x+X[i];
int ty=now.y+Y[i];
int tz=now.z+Z[i];
if (judge(tx,ty,tz)) {
q.push({tx,ty,tz});
visit[tx][ty][tz]=true;
//cnt++;
}
}
}
if (cnt>=K) return cnt;
return ;
}
int main () {
scanf ("%d %d %d %d",&n,&m,&l,&K);
for (int i=;i<l;i++)
for (int j=;j<n;j++)
for (int k=;k<m;k++)
scanf ("%d",&adj[j][k][i]);
int cnt=;
for (int i=;i<l;i++)
for (int j=;j<n;j++)
for (int k=;k<m;k++)
if (visit[j][k][i]==false&&adj[j][k][i]==) cnt+=bfs(j,k,i);
printf ("%d\n",cnt);
return ;
}
PAT A1091 Acute Stroke的更多相关文章
- PAT甲级——A1091 Acute Stroke【30】
One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the re ...
- A1091. Acute Stroke
One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the re ...
- PAT 1091 Acute Stroke [难][bfs]
1091 Acute Stroke (30 分) One important factor to identify acute stroke (急性脑卒中) is the volume of the ...
- PAT 1091. Acute Stroke (bfs)
One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the re ...
- PAT_A1091#Acute Stroke
Source: PAT A1091 Acute Stroke (30 分) Description: One important factor to identify acute stroke (急性 ...
- 【PAT】1091 Acute Stroke(30 分)
1091 Acute Stroke(30 分) One important factor to identify acute stroke (急性脑卒中) is the volume of the s ...
- 1091. Acute Stroke (30)
题目如下: One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given ...
- PAT1091:Acute Stroke
1091. Acute Stroke (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue One impo ...
- pat1091. Acute Stroke (30)
1091. Acute Stroke (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue One impo ...
随机推荐
- 截取字符,超出的用省略号代替js实现 substring
可用到截取文字过多的问题,取0到6之间的字符,不包含6title.substring(0,6)+'...';
- Opencv模块
参考博客:https://blog.csdn.net/u012679707/article/details/79505279
- 推荐一个手机端切换地址gps的app
在写脚本的时候遇到的 客户提供了这个app 免费 自身可以防检测 苹果和安卓都可以使用 官网 http://www.daniu.net/ 搜索 大牛 或者danniu即可
- go key-value缓存go-cache实现
Cache类型 Cache封装了一个cache类型,cache类型的参数解析: 1.defaultExpiration time.Duration 每个键值的默认过期时间. 2.items map[s ...
- 【Python collections】
目录 namedtuple deque Counter OrderedDict defaultdict "在内置数据类型(dict.list.set.tuple)的基础上,collectio ...
- yum源文件
yum源文件 2017年11月22日 11:59:36 cakincqm 阅读数 1052更多 分类专栏: Linux 版权声明:本文为博主原创文章,遵循CC 4.0 by-sa版权协议,转载请附 ...
- 关于windows nginx不能启动问题的解决,史上最坑系列之一(原文)
我是直接在官方网址下载windows1.6稳定版的nginx,之所以下载它是因为在window下方便学习,更好的在linux安装和学习nginx. 下载到D:\nginx学习\,解压它,并进入启动它 ...
- wampserver3.0.6 外网 不能访问
# 开始 今天在服务器上安装了wampserver3.0.6 然后在我的电脑浏览器上面打开服务器ip提示 Forbidden 下面一行小字提示没有权限访问"/"目录 # 解决 打开 ...
- mybatis实现有则更新无则插入
<insert id="insertUser" useGeneratedKeys="true" keyProperty="id" ke ...
- 【JavaWeb+Echarts+EL表达式】用图表形式展示数据
1. Echarts环境配置 https://www.echartsjs.com/zh/download.html 选择需要的,然后等待Build完成之后,就会自动弹出下载框啦! 把下载好的js放在w ...