17-比赛2 F - Fox And Two Dots (dfs)
#include<bits/stdc++.h>
using namespace std;
int n,m;
char Map[][];
bool book[][];
bool flag;
void dfs(int y,int x,int rey,int rex)
{
for(int i =;i<=;i++)
{
int ty=y,tx=x;
if(i==) ty++; //四个方向
if(i==) ty--;
if(i==) tx++;
if(i==) tx--;
if(ty<||ty>n||tx<||tx>m) continue;
if(ty==rey&&tx==rex) continue; //阻止往回走
if(Map[y][x]==Map[ty][tx]) //确保是相同的字母
{
if(book[ty][tx]==) {flag = ;break;}
book[ty][tx]=;
dfs(ty,tx,y,x);
}
}
return;
}
int main()
{
scanf("%d %d",&n,&m);
for(int y = ;y<=n;++y)
for(int x=;x<=m;++x)
{
cin>>Map[y][x];
} for(int y = ;y<=n;++y)
{
for(int x=;x<=m;++x)
{
if(book[y][x]==) continue;
book[y][x]=; //走过的点都标记上
dfs(y,x,,);
if(flag==) break;
}
if(flag==) break;
}
printf(flag==?"Yes\n":"No\n");
}
17-比赛2 F - Fox And Two Dots (dfs)的更多相关文章
- CF Fox And Two Dots (DFS)
Fox And Two Dots time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- Codeforces Round #290 (Div. 2) B. Fox And Two Dots dfs
B. Fox And Two Dots 题目连接: http://codeforces.com/contest/510/problem/B Description Fox Ciel is playin ...
- D - Fox And Two Dots DFS
Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on ...
- CodeForces - 510B Fox And Two Dots (bfs或dfs)
B. Fox And Two Dots time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- B. Fox And Two Dots
B. Fox And Two Dots time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Fox And Two Dots
B - Fox And Two Dots Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I6 ...
- CF510B Fox And Two Dots(搜索图形环)
B. Fox And Two Dots time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- 比赛安排(穷举法或dfs)
比赛安排 时间限制: 1 Sec 内存限制: 125 MB提交: 11 解决: 10[提交][状态][讨论版][命题人:外部导入] 题目描述 设有2n(n<=6)个球队进行单循环比赛,计划在 ...
- CF 510b Fox And Two Dots
Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on ...
随机推荐
- thinkphp 创建数据对象之data方法
创建数据对象:data()方法 1.功能:给模型对象$data赋值,将模型对象转化为数据对象 tip:模型对象与数据对象之间就差一个赋过值的$data; 2.方法:data()其源码如下: tip:源 ...
- canvas绘制阴影
- Visual Studio Code 入门教程
Extensible and customizable.(可扩展的和可定制的,这是我喜欢它的原因) Want even more features? Install extensions to add ...
- oracle 递归查询(来源于网络)
比如 a b a c a e b b1 b b2 c c1 e e1 e e3 d d1 指定parent=a,选出 a b a c a e b ...
- c#数据类型和表达式
一.数据类型 值类型: 1.整数(没有小数) Byte:字节0~255 Char:一个字符 Int 2.有小数 范围大的:double双 小范围:float单 最精确的:十进制decimal 3.bo ...
- u-boot分析(十一)----MMU简单分析|u-boot分析大结局|学习规划
u-boot分析(十一) 通过前面十篇博文,我们已经完成了对BL1阶段的分析,通过这些分析相信我们对u-boot已经有了一个比较深入的认识,在BL2阶段大部分是对外设的初始化,并且有的我们已经分析过, ...
- Eclipse JSP 页面设置 charset=UTF-8
windows —> Preferences —> 搜索框中输入:JSP,设置如下:
- .net 控制器调用外部链接传参方法
public class RequestHelper { /// <summary> /// 发起post请求 /// </summary> /// <typeparam ...
- 笨办法学Python(十六)
习题 16: 读写文件 如果你做了上一个练习的加分习题,你应该已经了解了各种文件相关的命令(方法/函数).你应该记住的命令如下: close – 关闭文件.跟你编辑器的 文件->保存.. 一个意 ...
- April 4 2017 Week 14 Tuesday
Problems are not stop signs, they are guidelines. 问题不是休止符,而是引向标. It is ture during our explorations ...