青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

comiz

a problem of maze

Problem Statement

People enjoy mazes, but they also get them dirty. Arrows, graffiti, and chewing gum are just a few of the souvenirs people leave on the walls. You, the maze keeper, are assigned to whiten the maze walls. Each face of the wall requires one liter of paint, but you are only required to paint visible faces. You are given a map of the maze, and you must determine the amount of paint needed for the job.

The maze is described by a vector <string> maze, where each character can be either '#' (a wall) or '.' (an empty space). All '.' characters on the perimeter of the map are considered entrances to the maze. Upon entering the maze, one can only move horizontally and vertically through empty spaces, and areas that are not reachable by these movements are not considered visible. Each '#' represents a square block with four wall faces (each side of the square is a face). A face is visible if it is not directly adjacent to another wall (and is in a reachable area of the maze). For example, two adjacent blocks can have at most six visible faces since two of their faces are directly adjacent to each other. All exterior faces on the perimeter are considered visible.

For example, the following picture represents a trivial maze with just one (wide) entrance and only four empty reachable spaces:

 TroytownKeeper.png

To whiten this maze you must paint the faces highlighted in yellow above: 16 for its perimeter, plus 8 interior faces. Note that there are faces that are not visible and thus need not be painted.

Definition     

Class: TroytownKeeper

Method: limeLiters Parameters: vector <string>

Returns: int

Method signature: int limeLiters(vector <string> maze)

(be sure your method is public)     

Constraints

- maze will contain between 1 and 50 elements, inclusive.

- Each element of maze will contain between 1 and 50 characters, inclusive.

- All elements of maze will have the same number of characters.

- All characters in maze will be either '.' or '#' . Examples 0)  

 

   

{"##..#",
"#.#.#",
"#.#.#",
"#####"}
Returns: 24

posted on 2007-11-04 19:35 comiz 閱讀(427) 評論(1)  編輯 收藏 引用

評論

# re: a problem of maze 2007-11-04 19:35 comiz

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Threading;

namespace TroytownKeeper
{

public class TroytownKeeper
{
string [] maze;
bool [,]used=new bool[100,100];
int sum=0;
public TroytownKeeper()
{



}

public int LimeLiters(string [] maze)
{
this.maze=maze;
for(int x=0;x<maze.GetLength(0);x++)
{
if(maze[x][0]=='.') dfs(x,0);
if(maze[x][maze[0].Length-1]=='.') dfs(x,maze[0].Length-1);
}
for(int y=0;y<maze[0].Length-1;y++)
{
if(maze[0][y]=='.') dfs(0,y);
if(maze[maze.GetLength(0)-1][y]=='.') dfs(maze.GetLength(0)-1,y);
}

for(int x=0;x<maze.GetLength(0);x++)
for(int y=0;y<maze[0].Length;y++)
if(maze[x][y]=='#')
{
//upside
if(x==0)
sum++;
if(x<maze.Length-1&&used[x+1,y])
sum++;
//leftside
if(y==0)
sum++;
if(y>0&&used[x,y-1])
sum++;
//underside
if(x==maze.Length-1)
sum++;
if(x>0&&used[x-1,y])
sum++;
//rightside
if(y==maze[0].Length-1)
sum++;
if(y<maze[0].Length-1&&used[x,y+1])
sum++;
}
return sum;
}

static void Main(string[] args)
{
TroytownKeeper TK=new TroytownKeeper();
string [] str={"##..#"
,"#.#.#"
,"#.#.#"
,"#####"};
int count=TK.LimeLiters(str);
Console.WriteLine(count.ToString());
}


void dfs(int x,int y)
{
used[x,y]=true;
if(x<maze.GetLength(0)&&maze[x+1][y]=='.'&&!used[x+1,y]) dfs(x+1,y);
if(y<maze[0].Length&&maze[x][y+1]=='.'&&!used[x,y+1]) dfs(x,y+1);
if(x>0&&maze[x-1][y]=='.'&&!used[x-1,y]) dfs(x-1,y);
if(y>0&&maze[x][y-1]=='.'&&!used[x,y-1]) dfs(x,y-1);
}
}
}

  回復  更多評論   


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


<2007年10月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

導航

統計

常用鏈接

留言簿(1)

隨筆檔案

搜索

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            老色鬼久久亚洲一区二区| 亚洲精品影视| 91久久夜色精品国产九色| 欧美精品在线观看| 亚洲一区二区三区精品在线观看| 久久亚洲影院| 亚洲视频中文字幕| 伊人久久久大香线蕉综合直播| 欧美日韩国产不卡在线看| 午夜精品久久久久久久99水蜜桃 | 欧美伊人久久| 亚洲精品国产日韩| 欧美影院精品一区| 在线成人av.com| 国产精品激情电影| 欧美大片一区二区三区| 久久精品国产亚洲精品| 亚洲私拍自拍| 亚洲日本黄色| 久久爱www.| 亚洲视频一区| 亚洲另类春色国产| 亚洲国产高清自拍| 国模套图日韩精品一区二区| 国产精品久久久久久妇女6080| 欧美成人高清| 久久综合999| 久久久久久久久久久久久女国产乱 | 日韩亚洲在线| 欧美激情视频网站| 久久全国免费视频| 小辣椒精品导航| 一区二区三区精品在线| 亚洲国产日韩一级| 在线精品国精品国产尤物884a| 国产精品99免费看| 欧美精品在线观看| 久久婷婷蜜乳一本欲蜜臀| 亚洲欧洲日本mm| 欧美激情在线狂野欧美精品| 老牛国产精品一区的观看方式| 久久久蜜桃一区二区人| 久久精品99| 久久久久久9999| 欧美一区网站| 久久精品99无色码中文字幕| 一区二区三区国产精华| 亚洲成人在线网| 日韩一级精品| 亚洲资源av| 久久久99久久精品女同性| 久久精品99国产精品| 久久精品一区| 欧美在线播放视频| 欧美一区二区三区视频免费| a4yy欧美一区二区三区| 亚洲国产高清一区二区三区| 亚洲国产欧美久久| 亚洲乱码国产乱码精品精| av成人免费| 中文精品99久久国产香蕉| 亚洲午夜精品久久| 午夜精品久久久久久久久久久久| 欧美在线二区| 久久精品国产久精国产思思| 亚洲欧美不卡| 久久福利一区| 美女爽到呻吟久久久久| 亚洲国产精品v| 日韩一区二区精品在线观看| 国产精品99久久久久久久vr| 亚洲中字在线| 久久久亚洲高清| 久久久久久久久综合| 久久精品亚洲一区二区| 裸体歌舞表演一区二区| 欧美日本视频在线| 欧美吻胸吃奶大尺度电影| 国产精品亚洲一区| 一区二区三区自拍| 日韩天堂在线观看| 亚洲欧美中文另类| 欧美一级播放| 欧美www视频在线观看| 亚洲精选在线观看| 亚洲欧美国产另类| 另类av一区二区| 欧美视频观看一区| 国产在线观看91精品一区| 亚洲黄色一区二区三区| 亚洲欧洲精品成人久久奇米网| 一区二区三区精密机械公司| 久久激情视频| 亚洲精品中文字| 欧美在线播放一区| 欧美国产大片| 国产亚洲观看| 99视频热这里只有精品免费| 欧美一进一出视频| 欧美国产精品久久| 亚洲午夜一级| 欧美a级理论片| 国产欧亚日韩视频| 亚洲毛片播放| 久久久久久久波多野高潮日日| 亚洲欧洲综合另类| 亚洲开发第一视频在线播放| 亚洲欧美日韩在线不卡| 欧美大尺度在线观看| 国产片一区二区| 日韩视频免费大全中文字幕| 久久精品国产综合| 日韩香蕉视频| 性欧美办公室18xxxxhd| 欧美久久电影| 韩国三级在线一区| 亚洲精品日韩欧美| 久久久www成人免费毛片麻豆| 亚洲美女色禁图| 老司机aⅴ在线精品导航| 国产精品久久久久毛片大屁完整版| 91久久国产综合久久91精品网站| 久久精品99| 亚洲香蕉视频| 女主播福利一区| 欧美色区777第一页| 亚洲国产天堂久久综合网| 久久九九99视频| 亚洲一级黄色| 欧美日韩国产三区| 最新高清无码专区| 老牛嫩草一区二区三区日本| 久久精品麻豆| 国内精品久久久久影院优| 午夜激情亚洲| 亚洲视频综合| 国产精品qvod| 亚洲夜间福利| 洋洋av久久久久久久一区| 欧美aa在线视频| 一本色道久久综合狠狠躁篇怎么玩 | 亚洲国产一区二区三区在线播| 欧美成人精品福利| 欧美成在线视频| 亚洲视频精选| 亚洲欧美国产一区二区三区| 国产日韩在线视频| 蜜臀av一级做a爰片久久| 狂野欧美激情性xxxx欧美| 亚洲老司机av| 亚洲最新在线| 国产欧美韩国高清| 久久精品一二三| 老司机凹凸av亚洲导航| 日韩午夜在线| 在线亚洲高清视频| 国产三区精品| 欧美a级大片| 欧美日韩精品免费在线观看视频| 午夜精品成人在线视频| 欧美在线中文字幕| 亚洲经典在线看| 一区二区三区欧美| 国产综合在线看| 亚洲国产成人av| 国产精品国产三级国产普通话99| 久久国产福利国产秒拍| 久热综合在线亚洲精品| 一区二区免费看| 午夜免费久久久久| 亚洲第一在线综合网站| 亚洲日韩成人| 国产三区二区一区久久 | 亚洲国产成人不卡| 欧美午夜视频在线| 久久久天天操| 欧美日韩国产另类不卡| 久久久91精品国产| 免费成人高清| 羞羞漫画18久久大片| 美女诱惑一区| 亚洲欧美在线播放| 美女成人午夜| 欧美中文字幕久久| 欧美激情一区二区| 久久久97精品| 国产精品xxx在线观看www| 免费视频一区| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ入口 | 1000精品久久久久久久久| 亚洲精品一区二区在线| 国产一区二区三区免费不卡| 亚洲激情在线观看视频免费| 国产欧美日韩麻豆91| 亚洲日产国产精品| 精品成人一区二区三区| 在线亚洲成人| 日韩视频一区二区三区在线播放免费观看| 亚洲欧美国产日韩天堂区| 99视频精品免费观看|