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 ...
随机推荐
- 跨平台C++ IDE
参考博客:https://blog.csdn.net/m0_37314675/article/details/77881287
- 关于AutoCompleteTextView的用法:根据输入的自动匹配关键词
- python爬虫-----Python访问http的几种方式
爬取页面数据,我们需要访问页面,发送http请求,以下内容就是Python发送请求的几种简单方式: 会使用到的库 urllib requests 1.urlopen import urllib. ...
- GIL/Copy/私有/面向对象
1. GIL Python语言和GIL没有关系.仅仅是由于历史原因在Cpython虚拟机(解释器),难以移除GIL. GIL:全局解释器锁.每个线程在执行的过程都需要先获取GIL,保证同一时刻只有一个 ...
- GEE引擎假人系统自定义教程
现如今传奇游戏玩家数量日渐减少.为了给服务器增加人气,很多GM在服务端中增加了自动登录和自动打怪的假人系统.由于该系统登录的假人可以自动练功,自动攻城和实现简单的对话.完全可以做到以假乱真的地步!所以 ...
- Linux centos7 shell 介绍、 命令历史、命令补全和别名、通配符、输入输出重定向
一.shell介绍 shell脚本是日常Linux系统管理工作中必不可少的,不会shell,就不是一个合格管理员. shell是系统跟计算机硬件交互使用的中间介质,一个系统工具.实际上在shell和计 ...
- python-线程池的两种实现方式 【转载】
#!/usr/bin/env python # -*- coding:utf-8 -*- import queue import threading import contextlib import ...
- TD tree体验
在体验了学长们设计的app后,我颇有感触,我们也可以凭借自己的力量来开发一款软件,虽然它可能并不如市面上相同类型的那么完美,但它对我们的意义却是不一样的. 我是在下午的见面会上看到的这款软件,接待的学 ...
- 吴裕雄 python 神经网络——TensorFlow 完整神经网络样例程序
import tensorflow as tf from numpy.random import RandomState batch_size = 8 w1= tf.Variable(tf.rando ...
- tensorflow之tensorboard
参考https://www.cnblogs.com/felixwang2/p/9184344.html 边学习,边练习 # https://www.cnblogs.com/felixwang2/p/9 ...