题意:

输入四个正整数M,N,K,T(K<=60,M<=1286,N<=128),代表每片的高度和宽度,片数和最小联通块大小。输出一共有多少个单元满足所在联通块大小大于等于T。

trick:

三元数组大小开小了。。。最后两个测试点答案错误,我是笨比。

AAAAAccepted code:

 #define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int m,n,l,t;
int a[][][];
int vis[][][];
int ans[][][];
int xx[]={,,,,-,,};
int yy[]={,,,,,-,};
int zz[]={,,,,,,-};
typedef struct nod{
int x,y,z;
};
queue<nod>q;
void dfs(int x,int y,int z){
while(!q.empty()){
++ans[x][y][z];
nod now=q.front();
q.pop();
for(int i=;i<=;++i){
int tx=now.x+xx[i];
int ty=now.y+yy[i];
int tz=now.z+zz[i];
if(!vis[tx][ty][tz]&&a[tx][ty][tz]==){
nod node;
node.x=tx;
node.y=ty;
node.z=tz;
vis[tx][ty][tz]=;
q.push(node);
}
}
}
}
void clear(queue<nod>&q){
queue<nod>emp;
swap(q,emp);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>m>>n>>l>>t;
for(int i=;i<=l;++i)
for(int j=;j<=m;++j)
for(int k=;k<=n;++k)
cin>>a[i][j][k];
int sum=;
for(int i=;i<=l;++i)
for(int j=;j<=m;++j)
for(int k=;k<=n;++k)
if(a[i][j][k]==&&!vis[i][j][k]){
clear(q);
nod tamp;
tamp.x=i;
tamp.y=j;
tamp.z=k;
q.push(tamp);
vis[i][j][k]=;
dfs(i,j,k);
if(ans[i][j][k]>=t)
sum+=ans[i][j][k];
}
cout<<sum;
return ;
}

【PAT甲级】1091 Acute Stroke (30 分)(BFS)的更多相关文章

  1. PAT甲级1091 Acute Stroke【三维bfs】

    题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805375457411072 题意: 求三维的连通块 思路: 简单b ...

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

    1091 Acute Stroke(30 分) One important factor to identify acute stroke (急性脑卒中) is the volume of the s ...

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

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

  4. PAT甲级——A1091 Acute Stroke【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. PAT 甲级 1080 Graduate Admission (30 分) (简单,结构体排序模拟)

    1080 Graduate Admission (30 分)   It is said that in 2011, there are about 100 graduate schools ready ...

  7. PAT 甲级 1072 Gas Station (30 分)(dijstra)

    1072 Gas Station (30 分)   A gas station has to be built at such a location that the minimum distance ...

  8. PAT 甲级 1049 Counting Ones (30 分)(找规律,较难,想到了一点但没有深入考虑嫌麻烦)***

    1049 Counting Ones (30 分)   The task is simple: given any positive integer N, you are supposed to co ...

  9. PAT 甲级 1030 Travel Plan (30 分)(dijstra,较简单,但要注意是从0到n-1)

    1030 Travel Plan (30 分)   A traveler's map gives the distances between cities along the highways, to ...

随机推荐

  1. ORA-01830

    问题:varchar2类型转换成date类型 select to_date(INVOICE_DATE,'yyyy-mm-dd') from tab; 提示 ORA-01830: 日期格式图片在转换整个 ...

  2. 计算a除b的第一位小数 in C++.

    my codes: #include<iostream> #include<cstdio> using namespace std; int main() { int a,b; ...

  3. IntelliJ IDEA常规配置教程

      IntelliJ IDEA,是java编程语言开发的集成环境.IntelliJ在业界被公认为最好的java开发工具,尤其在智能代码助手.代码自动提示.重构.J2EE支持.各类版本工具(git.sv ...

  4. adb shell 杀进程以及端口占用,adbserver服务重启失败

    linux: adb shell  ps |grep  netease 杀进程: adb shell kill [PID] //杀死进程 C:\Users\chenquan>adb shell ...

  5. 1、spring与springmvc父子容器

    转载于http://www.tianshouzhi.com/api/tutorials/spring 1.0 spring与springmvc父子容器 1.spring和springmvc父子容器概念 ...

  6. CF div2

    这是一道二进制思维题: 将所有数字列成二进制形式,然后找出最大的一位“1”出现一次的位数: 然后把这个数提到前面,其他照常输出即可 #include<bits/stdc++.h> usin ...

  7. [Luogu]小Z的AK计划

    Description Luogu2107 Solution 一开始打了一个60分的暴力DP,结果一分都没得--本地调了好久才发现是没开long long. 由于我的DP方程没有任何性质,就是一个01 ...

  8. Oracle的表空间、用户和表的区别和联系

    Oracle的表空间.用户和表的区别和联系 Oracle数据库是通过表空间来存储实际存在的那些表.索引.视图的, 表空间分类: 临时表空间:   用于存储数据库中单持久性模型对象,如表.索引.视图等, ...

  9. 在页面跳转的时候,在跳转后的页面中使用js 获取到 页面跳转的url中携带的参数。

    common.js代码 //获取URL中的参数..等等function getQueryString(name){var reg = new RegExp("(^|&)"+ ...

  10. 如何开通linux机器的对外访问端口

    1.先查看是否已经开通 2.没有开通,去linux机器查看防火墙,确实没有开通 3.修改防火墙 vim /etc/sysconfig/iptables 4.重启防火墙之后重新查看已经可以看到8000端 ...