K - Children of the Candy Corn

Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

The cornfield maze is a popular Halloween treat. Visitors are shown the entrance and must wander through the maze facing zombies, chainsaw-wielding psychopaths, hippies, and other terrors on their quest to find the exit.

One popular maze-walking strategy guarantees that the visitor will eventually find the exit. Simply choose either the right or left wall, and follow it. Of course, there's no guarantee which strategy (left or right) will be better, and the path taken is seldom the most efficient. (It also doesn't work on mazes with exits that are not on the edge; those types of mazes are not represented in this problem.)

As the proprieter of a cornfield that is about to be converted into a maze, you'd like to have a computer program that can determine the left and right-hand paths along with the shortest path so that you can figure out which layout has the best chance of confounding visitors.

Input

Input to this problem will begin with a line containing a single integer n indicating the number of mazes. Each maze will consist of one line with a width, w, and height, h (3 <= w, h <= 40), followed by h lines of w characters each that represent the maze layout. Walls are represented by hash marks ('#'), empty space by periods ('.'), the start by an 'S' and the exit by an 'E'.

Exactly one 'S' and one 'E' will be present in the maze, and they will always be located along one of the maze edges and never in a corner. The maze will be fully enclosed by walls ('#'), with the only openings being the 'S' and 'E'. The 'S' and 'E' will also be separated by at least one wall ('#').

You may assume that the maze exit is always reachable from the start point.

Output

For each maze in the input, output on a single line the number of (not necessarily unique) squares that a person would visit (including the 'S' and 'E') for (in order) the left, right, and shortest paths, separated by a single space each. Movement from one square to another is only allowed in the horizontal or vertical direction; movement along the diagonals is not allowed.

Sample Input

2
8 8
########
#......#
#.####.#
#.####.#
#.####.#
#.####.#
#...#..#
#S#E####
9 5
#########
#.#.#.#.#
S.......E
#.#.#.#.#
#########

Sample Output

37 5 5 17 17 9

//还没看懂题

K - Children of the Candy Corn(待续)的更多相关文章

  1. poj 3083 Children of the Candy Corn

    点击打开链接 Children of the Candy Corn Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8288 ...

  2. Children of the Candy Corn 分类: POJ 2015-07-14 08:19 7人阅读 评论(0) 收藏

    Children of the Candy Corn Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10933   Acce ...

  3. POJ3083——Children of the Candy Corn(DFS+BFS)

    Children of the Candy Corn DescriptionThe cornfield maze is a popular Halloween treat. Visitors are ...

  4. POJ 3083 Children of the Candy Corn bfs和dfs

      Children of the Candy Corn Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8102   Acc ...

  5. POJ 3083:Children of the Candy Corn(DFS+BFS)

    Children of the Candy Corn Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9311 Accepted: ...

  6. poj3083 Children of the Candy Corn BFS&&DFS

    Children of the Candy Corn Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11215   Acce ...

  7. POJ 3083 -- Children of the Candy Corn(DFS+BFS)TLE

    POJ 3083 -- Children of the Candy Corn(DFS+BFS) 题意: 给定一个迷宫,S是起点,E是终点,#是墙不可走,.可以走 1)先输出左转优先时,从S到E的步数 ...

  8. POJ 3083:Children of the Candy Corn

    Children of the Candy Corn Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11015   Acce ...

  9. POJ 3083 Children of the Candy Corn 解题报告

    最短用BFS即可.关于左手走和右手走也很容易理解,走的顺序是左上右下. 值得注意的是,从起点到终点的右手走法和从终点到起点的左手走法步数是一样. 所以写一个左手走法就好了.贴代码,0MS #inclu ...

随机推荐

  1. KBengine Learning Note 1 => Run Demo

    感觉周末没事就喜欢折腾点东西,看到KBengine这一款开源服务器引擎,之前也研究过一阵子Photon,但是要收费,弃之.觉得不错,研究下,顺便记录之. 启动环境 首先需要装好MySql与Python ...

  2. android 完美的tabhost 切换多activity布局

    TabHost在很多应用都会使用到,有时候在TabHost添加的Tab中设置view不能满足需求,因为在view中添加如PreferenceActivity相当困难. 之前在一个应用中需要实现使用Ta ...

  3. 【Java】Java_12 Eclipse

    1.eclipse简介 Eclipse 是一个开放源代码的.基于Java的可扩展开发平台.就其本身而言,它只是一个框架和一组服务,用于通过插件组件构建开发环境. 尽管 Eclipse 是使用Java语 ...

  4. 谷歌Cartographer学习 -快速安装测试

    参考资料:https://www.cnblogs.com/hitcm/p/5939507.html PC下面进行安装: 遇到的问题如下 1.首先安装ceres solver 在编译的时候,如果是低配的 ...

  5. C# socket编程 使用udp实现单对单的连接对话

    ipLocalPoint = new IPEndPoint(IPAddress.Parse("192.168.31.122"), 5000); //定义网络类型,数据连接类型和网络 ...

  6. python使用单例模式创建MySQL链接

    代码: from functools import wraps import mysql.connector from sshtunnel import SSHTunnelForwarder def ...

  7. JanusGraph与Cassandra集成模式

    //如果使用的是cassandra 2.2或更高版本,需要开启thift,以使janus连接到cassandra. ./bin/nodetool enablethrift. 15.1 Local Se ...

  8. Angularjs学习笔记2_添加删除DOM元素

    1.调用element方法     angular.element(html) 把字符串或dom对象转化成一JQuery对象, angular.element(document.getElementB ...

  9. C语言基础(20)-文件操作(fopen,getc,fclose)

    一.文件操作 读文件的顺序: 1.先打开文件 2.读写文件 3.关闭文件 1.1 fopen FILE *fopen( const char *path, const char *mode ); 函数 ...

  10. __attribute__系列之介绍篇

    1.什么是__attribute__? __attribute__机制是GNU C的一大特色,它可以设置函数属性.变量属性和类型属性等.可以通过它们向编译器提供更多数据,帮助编译器执行优化等. 2._ ...