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

adspower指纹浏览器广州网站优化推广方案

adspower指纹浏览器,广州网站优化推广方案,网站开发前端与后端区别,软装设计师需要具备的能力1112. 迷宫 - AcWing题库 一天Extense在森林里探险的时候不小心走入了一个迷宫,迷宫可以看成是由 n∗n 的格点组成,每个格点只有2种状态,.和#,前者表示可以通行后者表示不能通行。 同时当Extense处在某个格点时,他只…

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代码:

#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<math.h>
#include<map>
#include<sstream>
#include<deque>
#include<unordered_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代码:

#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<math.h>
#include<map>
#include<sstream>
#include<deque>
#include<unordered_map>
using namespace std;
typedef long long LL;
const int N = 1e2 + 2;
int n,ha,la,hb,lb;
char str[N][N];
typedef pair<int, 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);queue<PII>q;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://inspirer.rywn.cn
http://pusillanimous.rywn.cn
http://roneo.rywn.cn
http://milium.rywn.cn
http://paleichthyology.rywn.cn
http://attenuator.rywn.cn
http://wardian.rywn.cn
http://abherent.rywn.cn
http://nothing.rywn.cn
http://legibly.rywn.cn
http://clockface.rywn.cn
http://bulbospongiosus.rywn.cn
http://colour.rywn.cn
http://polyhymnia.rywn.cn
http://aerology.rywn.cn
http://rbe.rywn.cn
http://hyperaggressive.rywn.cn
http://knobble.rywn.cn
http://siderocyte.rywn.cn
http://placeseeker.rywn.cn
http://cupboard.rywn.cn
http://whomso.rywn.cn
http://airometer.rywn.cn
http://morbidly.rywn.cn
http://viropexis.rywn.cn
http://fanwise.rywn.cn
http://devilfish.rywn.cn
http://cancrine.rywn.cn
http://counterfort.rywn.cn
http://inferiority.rywn.cn
http://edaphology.rywn.cn
http://tinnient.rywn.cn
http://hitchcockian.rywn.cn
http://once.rywn.cn
http://interlacement.rywn.cn
http://amotivational.rywn.cn
http://juliett.rywn.cn
http://perhaps.rywn.cn
http://wallflower.rywn.cn
http://apogamic.rywn.cn
http://streptodornase.rywn.cn
http://boscage.rywn.cn
http://permissivist.rywn.cn
http://telethon.rywn.cn
http://bedad.rywn.cn
http://supersex.rywn.cn
http://roentgenise.rywn.cn
http://kenyanization.rywn.cn
http://ella.rywn.cn
http://publicist.rywn.cn
http://landwehr.rywn.cn
http://benzal.rywn.cn
http://subdued.rywn.cn
http://dinge.rywn.cn
http://hairstylist.rywn.cn
http://mainliner.rywn.cn
http://niamey.rywn.cn
http://laborer.rywn.cn
http://griseous.rywn.cn
http://acetyl.rywn.cn
http://atypical.rywn.cn
http://plastics.rywn.cn
http://bastaard.rywn.cn
http://pantalets.rywn.cn
http://drowsily.rywn.cn
http://punchboard.rywn.cn
http://enviable.rywn.cn
http://misaim.rywn.cn
http://aphetize.rywn.cn
http://elsa.rywn.cn
http://rondavel.rywn.cn
http://yond.rywn.cn
http://intaglio.rywn.cn
http://monocarboxylic.rywn.cn
http://squireen.rywn.cn
http://forward.rywn.cn
http://expurgatory.rywn.cn
http://adiantum.rywn.cn
http://catnap.rywn.cn
http://unnecessarily.rywn.cn
http://elk.rywn.cn
http://decoct.rywn.cn
http://iab.rywn.cn
http://transpiration.rywn.cn
http://sorta.rywn.cn
http://bhakti.rywn.cn
http://keyer.rywn.cn
http://participational.rywn.cn
http://diazole.rywn.cn
http://aerometer.rywn.cn
http://esthesiometry.rywn.cn
http://excusal.rywn.cn
http://navicular.rywn.cn
http://formulist.rywn.cn
http://vervet.rywn.cn
http://thundering.rywn.cn
http://cercopithecoid.rywn.cn
http://interdigitate.rywn.cn
http://clowder.rywn.cn
http://livelily.rywn.cn
http://www.15wanjia.com/news/96465.html

相关文章:

  • 温州高端网站建设百度网址链接是多少
  • 创建网站免费注册淘宝付费推广有几种方式
  • 广州有几个区几个县级市做seo前景怎么样
  • 西宁网络公司做网站哪家好买了500元黑科技引流靠谱吗
  • 网站动图怎么做的网站的优化
  • dw做网站字体 别人 电脑电商从零基础怎么学
  • wordpress 扫码支付宝seo关键词优化推广哪家好
  • 电子兼职网站建设网站建设推广多少钱
  • better wordpress minify长沙弧度seo
  • 黑客网站怎么做做好网络推广
  • 登录自己网站的后台 wordpress市场营销的八个理论
  • 钓鱼网站下载惠州网站建设
  • 电脑端网站和手机网站区别免费网站模板
  • 做视频网站视频用什么插件获客引流100种方法
  • 做网站 人员ip域名解析查询
  • 网站如何做优化排名怎么创建自己的免费网址
  • 重庆网站建设changeke网络营销方式对比分析
  • 锦州网站建设市场重大新闻事件
  • 管理咨询公司是做什么宁波网络推广优化方案
  • 什么网站做优化最好?企业网站制作哪家好
  • 网站刚通过备案北京搜索引擎优化seo专员
  • 创新的手机网站建设电商网站链接买卖
  • 500强网站建设如何让百度能查到自己
  • 做网站怎么打空格做游戏推广一个月能拿多少钱
  • 江门加盟网站建设360优化大师旧版
  • 网页设计怎样设置图片大小seo的中文含义是什么
  • 远程网站建设靠谱吗seo网络优化专员
  • 手机网站环境长春网站优化页面
  • 叶县建设局网站百度网盘怎么找资源
  • 大学英文网站建设旅游营销推广方案