【PAT甲级】1091 Acute Stroke (30 分)(BFS)
题意:
输入四个正整数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)的更多相关文章
- PAT甲级1091 Acute Stroke【三维bfs】
题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805375457411072 题意: 求三维的连通块 思路: 简单b ...
- 【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)(30 分)
One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the re ...
- PAT甲级——A1091 Acute Stroke【30】
One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the re ...
- 1091. Acute Stroke (30)
题目如下: One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given ...
- PAT 甲级 1080 Graduate Admission (30 分) (简单,结构体排序模拟)
1080 Graduate Admission (30 分) It is said that in 2011, there are about 100 graduate schools ready ...
- 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 ...
- PAT 甲级 1049 Counting Ones (30 分)(找规律,较难,想到了一点但没有深入考虑嫌麻烦)***
1049 Counting Ones (30 分) The task is simple: given any positive integer N, you are supposed to co ...
- 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 ...
随机推荐
- python3练习100题——014
这题卡了我一整天,然后还是看答案撸了一遍- 原题链接:http://www.runoob.com/python/python-exercise-example14.html 题目:将一个正整数分解质因 ...
- JAVASCRIPT实现的WEB页面跳转以及页面间传值方法
在WEB页面中,我们实现页面跳转的方法通常是用LINK,BUTTON LINK ,IMG LINK等等,由用户点击某处,然后直接由浏览器帮我们跳转. 但有时候,需要当某事件触发时,我们先做一些操作,然 ...
- python网络编程(通过tcp或者udp协议通信)
1.基于tcp协议传送文件: 客户端: import socketimport osimport jsonimport structclient = socket.socket()client.con ...
- 用控制台编译和运行,输出HelloWorld
HelloWorld 建立一个Java文件,文件后缀为.java(Hello.java) public class Hello{ public static void main(String[ ...
- JDK的卸载和安装
Java入门 Java最大优势:基于JVM,跨平台 Java的几个版本 JavaSE:标准版,占领桌面,桌面程序,控制台开发等. JavaME:嵌入式开发,占领手机,手机,小家电等.(几乎死掉了) J ...
- python selenium设计模式POM
POM模式是什么 页面对象模型(POM)是一种设计模式,用来管理维护一组web元素集的对象库 在POM模式下,应用程序的每一个页面都有一个对的page class 每一个page class维护着该w ...
- 钉钉、钉应用(微应用和E应用)开发介绍
钉钉,数字化新工作方式,让工作更简单 目前在钉钉的官网可以看到,超过700万家企业组织正在使用钉钉.笔者也相信,这一数字每天都在增加.获得群众的认可,也是理所当然的,体验过钉钉,就能感觉到,钉钉的考勤 ...
- wamp修改MySQL密码
wamp默认密码为空 用户名为root: 左击wamp绿色小图标,打开phpMyAdmin ->执行 ->账号 ->找到用户名为root的修改权限&&点击修改权限 - ...
- bzoj 4827: [HNOI2017]礼物 (FFT)
一道FFT 然而据说暴力可以水70分 然而我省选的时候看到了直接吓傻了 连暴力都没打 太弱了啊QAQ emmmm 详细的拆开就看其他题解吧233 最后那一步卷积其实我一直没明白 后来画画图终于懂了 ...
- Equalize
You are given two binary strings aa and bb of the same length. You can perform the following two ope ...