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 ...
随机推荐
- Mysql慢查询 [第二篇]
一.简介 pt-query-digest是用于分析mysql慢查询的一个工具,它可以分析binlog.General log.slowlog,也可以通过SHOWPROCESSLIST或者通过tcpdu ...
- vue中 eCharts 自适应容器
在 vue 脚手架开发中,echarts图表自适应容器的方法: 父组件: <template> <div class="statistics_wrap"> ...
- 用代码初始化AE控件许可
当AE二次开发与其他平台一起使用的时候,有时候会不方便加LicenseControl控件,需要用代码初始化许可: 在构造函数中初始化许可: public Form1() { InitializeCom ...
- 利用批处理结合Msbuild实现快速编译
我们经常在用vs2005做项目的时候会把一个项目分成几个模块(不管是对于功能上,还是系统构架上面),为的是以后部署,还有修改维护时候的方便.这样就会带来一个问题,随着模块的增加(这里所说得每个模块就是 ...
- python 网址
https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/001431752945034e ...
- 使用selenium 检测js报错
背景:接到一个需求,想检测页面是否能检测js报错,何为js报错,如下图所示,在控制台中,使用console,如果有js报错,就会出现错误 如何检测,简单版操作,打开一个url,使用manage获取浏览 ...
- UIView设置阴影无效的原因之一
本想在底部的按钮设置个阴影, 代码如下: self.layer.shadowColor = [UIColor blackColor].CGColor; self.layer.shadowOffset ...
- 0x40二分法
二分模板一共有两个,分别适用于不同情况.算法思路:假设目标值在闭区间[l, r]中, 每次将区间长度缩小一半,当l = r时,我们就找到了目标值. 版本1 在单调递增序列a中查找>=x的数中最小 ...
- CentOS安装配置MongoDB
1.下载安装包: wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-2.0.3.tgz 2.解压: tar -zxvf mongodb-l ...
- Thinkphp 5 使用DOMDocument
每一个载入浏览器都会生成一个 Document 对象. Document 对象使我们可以从脚本中对 HTML 页面中的所有元素进行访问.Document 对象是 Window 对象的一部分. 我们项目 ...