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

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>
            久久黄色影院| 一本色道久久综合亚洲精品按摩| 亚洲一区二区综合| 国产精品yjizz| 亚洲综合第一页| 亚洲一区免费| 国产精品一区二区黑丝| 欧美一区二区三区免费大片| 午夜精品久久久久99热蜜桃导演| 国产三区精品| 蜜桃av久久久亚洲精品| 欧美成人福利视频| 一区二区欧美亚洲| 亚洲视频日本| 今天的高清视频免费播放成人 | 久久精品女人| 久久黄色级2电影| 亚洲精品美女免费| 亚洲香蕉视频| 极品尤物久久久av免费看| 亚洲国产清纯| 欧美午夜电影在线| 久久综合狠狠综合久久综合88| 蜜乳av另类精品一区二区| 亚洲视频在线一区| 久久精品久久综合| 91久久精品国产91久久| 亚洲永久免费精品| 亚洲第一天堂无码专区| 国产精品99久久不卡二区| 一区二区在线观看视频在线观看 | 久久av老司机精品网站导航| 玖玖在线精品| 欧美一级久久| 欧美精品一区二| 久久久女女女女999久久| 欧美日韩成人在线视频| 美女亚洲精品| 国产精品美女久久久浪潮软件| 乱中年女人伦av一区二区| 欧美视频二区36p| 欧美激情一区在线观看| 国产欧美日韩亚洲精品| 99视频精品全部免费在线| 在线看国产一区| 欧美在线观看一区二区三区| 亚洲一二三区在线观看| 欧美激情网友自拍| 免费日韩成人| 狠狠久久综合婷婷不卡| 亚洲欧美999| 亚洲欧美国产精品va在线观看| 欧美高清不卡| 免费亚洲网站| 影音先锋在线一区| 亚洲精选视频免费看| 亚洲欧美中文日韩在线| 亚洲欧美视频在线| 欧美日韩一区二区在线播放| 亚洲国产精品va在看黑人| 亚洲国产精品久久久久秋霞蜜臀| 欧美一级大片在线观看| 久久精彩免费视频| 国产欧美日韩综合| 性视频1819p久久| 欧美一区二区三区免费观看| 国产精品一区二区三区久久久| 一区二区日韩伦理片| 亚洲永久免费观看| 国产精品久久久久影院亚瑟| 一区二区三区四区五区在线| 亚洲综合精品一区二区| 欧美视频中文一区二区三区在线观看| 91久久久久久久久| 99re6热在线精品视频播放速度| 欧美国产精品| 一本色道久久综合精品竹菊| 午夜精品福利一区二区三区av| 国产精品久久久久aaaa樱花| 亚洲综合色在线| 久久久久久久高潮| 极品少妇一区二区三区| 欧美成人久久| 在线亚洲一区二区| 欧美一区日韩一区| 伊人成年综合电影网| 免费亚洲一区二区| 99精品免费| 久久精品视频网| 亚洲国产成人久久| 欧美日韩国内自拍| 午夜性色一区二区三区免费视频| 久久综合亚州| 一本久道久久综合狠狠爱| 国产精品视频你懂的| 久久天天躁狠狠躁夜夜爽蜜月| 亚洲黄色高清| 午夜精品久久久久久久久久久久久| 国产欧美日韩一级| 欧美高清在线视频观看不卡| 亚洲一级一区| 欧美黑人一区二区三区| 亚洲免费在线精品一区| 精品动漫av| 欧美三级视频在线播放| 久久久久久久久久码影片| 亚洲免费不卡| 麻豆freexxxx性91精品| 国产精品99久久久久久宅男 | 欧美婷婷久久| 久久久成人精品| 艳妇臀荡乳欲伦亚洲一区| 久热综合在线亚洲精品| 久久久五月婷婷| 一本色道久久综合亚洲精品按摩| 麻豆精品视频在线| 亚洲男人的天堂在线aⅴ视频| 在线国产精品播放| 国产精品欧美风情| 欧美精品成人| 免费av成人在线| 欧美一级电影久久| 在线中文字幕不卡| 亚洲第一区中文99精品| 久久天天狠狠| 久久成人免费日本黄色| 亚洲私人影院在线观看| 亚洲欧洲精品成人久久奇米网| 国产亚洲午夜| 国产精品一区在线观看| 欧美日韩久久| 麻豆freexxxx性91精品| 久久精品91久久香蕉加勒比 | 欧美夫妇交换俱乐部在线观看| 午夜精品福利一区二区蜜股av| 一区二区三区精品视频在线观看| 极品裸体白嫩激情啪啪国产精品| 国产女精品视频网站免费| 国产精品h在线观看| 欧美日韩在线精品一区二区三区| 欧美激情一二三区| 欧美高清视频| 欧美极品在线观看| 欧美激情中文字幕一区二区| 欧美电影在线播放| 欧美国产日韩一区二区在线观看| 免费观看一区| 欧美国产一区二区三区激情无套| 乱中年女人伦av一区二区| 老司机精品导航| 久久综合国产精品| 欧美99久久| 欧美欧美天天天天操| 欧美久久九九| 欧美午夜精品理论片a级按摩| 欧美色图一区二区三区| 国产精品裸体一区二区三区| 国产精品爽爽爽| 国产综合视频| 雨宫琴音一区二区在线| 亚洲欧洲偷拍精品| 亚洲一级网站| 久久激情中文| 欧美大片一区| 99热免费精品在线观看| 欧美一区二区三区在线看| 久久精品人人爽| 欧美国产日韩亚洲一区| 国产精品视频999| 伊人久久成人| 国产精品99久久久久久久久久久久 | 欧美福利视频在线| 欧美日韩精品一二三区| 国产欧美一级| 亚洲精品网站在线播放gif| 夜夜嗨av一区二区三区中文字幕 | 亚洲欧美另类在线观看| 久久精品日韩欧美| 欧美激情视频网站| 国产女同一区二区| 91久久综合| 欧美在线视频一区二区| 欧美高清视频免费观看| 99国内精品| 久久视频在线免费观看| 欧美视频一区二区| 尹人成人综合网| 亚洲女性裸体视频| 欧美高清视频在线| 午夜精品视频一区| 欧美日韩免费高清| 1769国产精品| 亚洲欧美乱综合| 亚洲黑丝一区二区| 中日韩男男gay无套| 牛夜精品久久久久久久99黑人 | 91久久在线视频| 欧美亚洲免费高清在线观看| 欧美精品一区二区久久婷婷| 精品成人久久|