当前位置: 首页 > news >正文

庆阳网红刘斌谷歌seo知识

庆阳网红刘斌,谷歌seo知识,视频拍摄公司,网站的访问量1112. 迷宫 - AcWing题库 一天Extense在森林里探险的时候不小心走入了一个迷宫#xff0c;迷宫可以看成是由 n∗n 的格点组成#xff0c;每个格点只有2种状态#xff0c;.和##xff0c;前者表示可以通行后者表示不能通行。 同时当Extense处在某个格点时#xff0c;他只…1112. 迷宫 - AcWing题库 一天Extense在森林里探险的时候不小心走入了一个迷宫迷宫可以看成是由 n∗n 的格点组成每个格点只有2种状态.和#前者表示可以通行后者表示不能通行。 同时当Extense处在某个格点时他只能移动到东南西北(或者说上下左右)四个方向之一的相邻格点上Extense想要从点A走到点B问在不走出迷宫的情况下能不能办到。 如果起点或者终点有一个不能通行(为#)则看成无法办到。 注意A、B不一定是两个不同的点。 输入格式 第1行是测试数据的组数 k后面跟着 k 组输入。 每组测试数据的第1行是一个正整数 n表示迷宫的规模是 n∗n 的。 接下来是一个 n∗n 的矩阵矩阵中的元素为.或者#。 再接下来一行是 4 个整数 ha,la,hb,lb描述 A 处在第 ha 行, 第 la 列B 处在第 hb 行, 第 lb 列。 注意到 ha,la,hb,lb 全部是从 0 开始计数的。 输出格式 k行每行输出对应一个输入。 能办到则输出“YES”否则输出“NO”。 数据范围 1≤n≤100 输入样例 2 3 .## ..# #.. 0 0 2 2 5 ..... ###.# ..#.. ###.. ...#. 0 0 4 0输出样例: YES NO 解析 使用dfs进行判断代码要比bfs简洁 dfs代码 #includeiostream #includestring #includecstring #includecmath #includectime #includealgorithm #includeutility #includestack #includequeue #includevector #includeset #includemath.h #includemap #includesstream #includedeque #includeunordered_map using namespace std; typedef long long LL; const int N 1e2 2; int n, ha, la, hb, lb; char str[N][N]; bool vis[N][N]; int dx[4] { -1,0,1,0 }, dy[4] { 0,1,0,-1 }; bool dfs(int x, int y) {if (str[x][y] #)return false;if (x hb y lb)return true;for (int i 0; i 4; i) {int a x dx[i], b y dy[i];if (a 0 || a n || b 0 || b n)continue;if (vis[a][b])continue;vis[a][b] 1;if (dfs(a, b))return true;}return false; }int main() {int T;cin T;while (T--) {cin n;for (int i 0; i n; i) {scanf(%s, str[i]);}cin ha la hb lb;memset(vis, 0, sizeof vis);if (dfs(ha, la))cout YES endl;else cout NO endl;}return 0; }BFS代码 #includeiostream #includestring #includecstring #includecmath #includectime #includealgorithm #includeutility #includestack #includequeue #includevector #includeset #includemath.h #includemap #includesstream #includedeque #includeunordered_map using namespace std; typedef long long LL; const int N 1e2 2; int n,ha,la,hb,lb; char str[N][N]; typedef pairint, int PII; bool vis[N][N];string bfs() {string ret1 YES, ret2 NO;if (str[ha][la] # || str[hb][lb] #)return ret2;int dx[4] { -1,0,1,0 }, dy[4] { 0,1,0,-1 };memset(vis, 0, sizeof vis);queuePIIq;q.push({ ha,la });vis[ha][la] 1;while (!q.empty()) {auto t q.front();q.pop();if (t.first hb t.second lb)return ret1;for (int i 0; i 4; i) {int a t.first dx[i], b t.second dy[i];if (a 0 || a n || b 0 || b n)continue;if (str[a][b] #||vis[a][b])continue;vis[a][b] 1;q.push({ a,b });}}return ret2; }int main() {int T;cin T;while (T--) {cin n;for (int i 0; i n; i) {scanf(%s, str[i]);}cin ha la hb lb;cout bfs() endl;}return 0; }
http://www.tj-hxxt.cn/news/136347.html

相关文章:

  • 电商网站建设网络公司网站建设洽谈问题
  • 电子商务网站域名注册方法做网站找哪家好
  • 做网站要签合同吗网站黑链
  • 胶东国际机场建设有限公司网站邯郸媒体网络营销诚信合作
  • 重庆市建设工程信息网站哪些网站教你做美食的
  • 关闭网站跳转代码亳州网站制作公司
  • 企业可以做哪些网站有哪些内容吗zencart网站建设
  • 网站建设招标文件技术部分纺织面料做哪个网站好
  • 如何取一个大气的名字的做网站平台公司的定义
  • 多终端网站百度关键词分析工具
  • 固原住房和城乡建设厅网站伊犁州建设局网站
  • 商业摄影网站wordpress 文章截断
  • 杭州建设局网站首页 柳免费制作主图的网站
  • 潍坊汇聚网站3a汽车集团公司网络营销方案
  • 无锡网站制作工具苏州网站制作网络建设公司
  • 网站会员功能介绍自己网站视频直播怎么做
  • 怎么用dw建设网站德州网站建设德州
  • 仙居做网站在哪里做网站建设公司 云智互联
  • 网站如何提高用户量网站建设服务器价格
  • 免费手机个人网站seo发布网站
  • 景观网站建设wordpress 改模板目录
  • 电影网站怎么做平面设计师网站都有哪些
  • 莲湖微网站建设如何注册公司费用
  • 自媒体运营小程序开发网站建设博客社区类网站模板下载
  • 短视频营销推广方式搜索引擎排名优化seo课后题
  • 怎么建设手机端网站如何防止网站被镜像
  • 阿里云虚拟主机建站教程中国做的最好的网站建设公司
  • 代做网站app苏州企业网站建站系统
  • 网站建设公司的市场营销方案无锡企业网站排名优化
  • 网站推广该怎么做网站建设推广服务商