题意:

输入四个正整数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. [CF603R] Game - 博弈论

    [CF603R] Description 给定 \(N \times N\) 的棋盘,两人轮流放棋子.棋子的上下左右四个格子不能再放棋子.不能操作的人负.判断胜负. Solution 用的是很常见的思 ...

  2. 利用python装饰器为字符串添加,HTML标签

    # 为字符串添加HTML标签 import time def zhuang(fun): def zhaung_1(*args, **kargs): # time.sleep(1) html_str = ...

  3. codeforces 1288C. Two Arrays(dp)

    链接:https://codeforces.com/contest/1288/problem/C C. Two Arrays 题意:给定一个数n和一个数m,让构建两个数组a和b满足条件,1.数组中所有 ...

  4. php多版本使用composer

    适用多版本的方法 1:下载composer.phar,官网有直接下载的链接,https://getcomposer.org/download/ 2:composer.phar 复制到项目根目录 3:p ...

  5. angular 读写电脑本地文件

    angular 读写本地电脑文件 angular将数据写进到电脑文件 在前端写一个按钮,然后点击按钮的时候在本地电脑保存一个text文件. 这时候我们需要用到一个angular的插件,叫做" ...

  6. Custom LED Keychain, Small And Surefire Gifts

    The    LED Keychain    makes it easy for people to carry their keys with them and carry them with th ...

  7. 十大常见web漏洞及防范

    十大常见web漏洞 一.SQL注入漏洞 SQL注入攻击(SQL Injection),简称注入攻击.SQL注入,被广泛用于非法获取网站控制权,是发生在应用程序的数据库层上的安全漏洞.在设计程序,忽略了 ...

  8. jsp页面直接读取mysql数据库数据显示

    jsp页面直接读取mysql数据库数据显示: <%@page import="java.sql.ResultSet"%> <%@page import=" ...

  9. nomon+ pyNmonAnalyzer实现基于python的nmon监控性能数据可视化

    pip install pyNmonAnalyzer nnmon  for linux from sourceforge:https://sourceforge.net/projects/nmon/ ...

  10. 使用prepareStatement执行的sql语句的写法:

    使用prepareStatement对象执行的增.删.改.查sql语句: 查:  String sql = "SELECT * FROM 表名 WHERE loginId=? AND pas ...