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 ...
随机推荐
- css float布局--右侧上部固定下部自适应大小
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 拖拽事件--select外边框拖拽
地图上面的搜索框要可拖拽 但是搜索框是有点击事件的,点击显隐下拉菜单,如果拖拽的事件源选择select框的话,会有样式(十字拖动符cursor:move与selelt默认点击的箭头)冲突 思索良久,就 ...
- C++ Knowledge series 2
Programming language evolves always along with Compiler's evolvement The semantics of constructors O ...
- python模块详解 time与date time
模块的分类: a:标准库 内置模块 如sys,os等 b:开源模块 大神封装好的 直接可以拿来用的. c:自定义模块 自己封装的模块 Python中通常表示时间的方式有:时间戳.格式化的日期.元组(九 ...
- 自顶向下理解Java集合框架(三)Map接口
Map基本概念 数据结构中Map是一种重要的形式.Map接口定义的是查询表,或称查找表,其用于储存所谓的键/值对(key-value pair),其中key是映射表的索引. JDK结构中还存在实现Ma ...
- SPFieldLookupValue
//得到查阅项的值SPWeb web = site.OpenWeb();SPList list = web.Lists["DemoList"];SPListItem item = ...
- Prestashop-1.6.1.6-zh_CN (Openlogic CentOS 7.2)
平台: CentOS 类型: 虚拟机镜像 软件包: prestashop1.6.1.6 commercial content management ecommerce open-source 简体中文 ...
- webpack gulp grunt 简单介绍
本文主要是讲下webpack的相关知识点,理论比较多,因为webpack的功能非常强大,说到的也基本都是经常用到的. 这三个工具都属于前端自动化的工具,都是第三方的,并且国内很多大型团队也都有自己成熟 ...
- python读入文档中的一行
从文件log_fusion中读入数据 方法1 f = open("log_fusion.txt") # 返回一个文件对象 line = f.readline() # 调用文件的 r ...
- window下mycat要放在根目录下
原理文档没有跟我开玩笑呢? 建议放在盘符根目录下 ,无视的我,检查了多遍jdk环境,检查了多遍bat文件内容,仍然没有解决 找不到或无法加载主类 直到我乖乖的把目录放跟盘符才解决,心好累= =! 可能 ...