题意:

输入四个正整数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. Android基础知识 -- Fragment

    Fragment是android3.0后提供的API(所以android:minSdkVersion="11"以上版本),主要针对平板UI.有自己的生命周期,但是必须依附在Acti ...

  2. python3练习100题——008

    今天第二道,做了明天就可以休息一下- 原题链接:http://www.runoob.com/python/python-exercise-example8.html 题目:输出 9*9 乘法口诀表. ...

  3. ssh连不上的问题

    新安装的ubuntu,想要ssh远程连接,发现连接不上,何解? 答 : 在ubuntu上安装ssh. sudo apt-get install openssh-server

  4. 来了,就给自己立个flag

    2019-09-16,刚刚申请的博客园. 不知道不觉,自己已经大四毕业了. 说来惭愧,已经接触IT这方面已经四年了. 但仍然感觉自己像个萌新,啥也不懂,这也不会,那也不会. 8月开始在公司大佬的指导下 ...

  5. CentOS7网络配置:静态IP和DHCP

    1.打开并编辑网络配置文件:/etc/sysconfig/network-scripts/ifcfg-ens33 [root@localhost network-scripts]# vim ifcfg ...

  6. [RedHat]“is not in the sudoers file”解决方法

    当在终端执行sudo命令时,系统提示“luckchengis not in the sudoers file”: $ sudo ls Password: luckcheng is not in the ...

  7. mediasoup-demo安装记录

    环境CentOS 7 64位 VMWare12虚拟机(win10主机),安装好NodeJS 10.13(大于8.9就可以) 已按照GitHub说明拉下来代码,配置好Node环境,开始执行npm sta ...

  8. 我的reshape观

    reshape(1,2)把结果分成1块,每一块2个元素 reshape(2,1)把结果分成2块,每一块1个元素 reshape(-1,1)把结果分成任意块,每一块1个元素 reshape(1,-1)把 ...

  9. string常用成员函数

    string常用成员函数 std::string::clear Clear string Erases the contents of the string, which becomes an emp ...

  10. Bug搬运工-CSCux99539:Intermittent error message "Power supply 2 failed or shutdown"

    Description Symptom:Following error messages will be seen intermittently.%PFMA-2-PS_FAIL: Power supp ...