记录详情

Accepted


  
# 状态 耗时 内存占用
#1 Accepted 1ms 220.0 KiB
#2 Accepted 1ms 220.0 KiB
#3 Accepted 1ms 224.0 KiB
#4 Accepted 1ms 220.0 KiB
#5 Accepted 1ms 216.0 KiB

代码

#include <bits/stdc++.h>
using namespace std;
const int N = 21;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
struct node{
	int x, y;
};
char mp[N][N];
bool vis[N][N];
queue<node>q; 

void bfs()
{
	q.push((node){1,1});
	while(!q.empty())
	{
		node u = q.front();q.pop();
		int x = u.x,y = u.y;
		if(x == 10 && y == 10){ puts("Yes");return; } 
		if(vis[x][y]) continue;
		vis[x][y] = 1;
		for(int i = 0;i < 4; i++)
		{
			int nx = x + dx[i],ny = y + dy[i];
			if(nx < 1 || nx > 10 || ny < 1 || ny > 10) continue;
			if(mp[nx][ny] != '.') continue;
			q.push((node){nx,ny}); 
		}
	}
	puts("No");
}

signed main()
{
	for(int i = 1;i <= 10; i++)
	    scanf("%s",mp[i] + 1);
	bfs();
}
/*
...#....#.
#..##...##
.#....#...
..#####..#
##...#..##
##.#...###
##.####...
##.##..###
##.....###
######....
*/ 

信息

递交者
类型
递交
题目
P1001 hitwh 2019 新生赛 B lxdlam 和他的迷宫
语言
C++
递交时间
2020-12-17 12:43:03
评测时间
2020-12-17 12:43:03
评测机
分数
100
总耗时
8ms
峰值内存
224.0 KiB