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

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>
            欧美影视一区| 欧美黄色网络| 国产亚洲精久久久久久| 亚洲男人第一网站| 亚洲欧美综合v| 国内精品免费在线观看| 久久一区欧美| 欧美成人一品| 亚洲影音一区| 欧美在线视频观看| 91久久精品美女高潮| 亚洲精品一区二区三区樱花| 欧美日韩情趣电影| 久久国产精品99国产精| 久久精品国产清高在天天线 | 亚洲黄色精品| 欧美日韩少妇| 久久久亚洲成人| 欧美freesex8一10精品| 亚洲女性喷水在线观看一区| 欧美亚洲专区| 99国产麻豆精品| 午夜精品福利在线观看| 亚洲国产乱码最新视频| 一区二区三区导航| 亚洲电影在线| 99精品国产高清一区二区| 国产一区二区三区久久悠悠色av| 欧美国产日韩在线观看| 国产精品v日韩精品| 免费日韩成人| 国产精品免费视频xxxx| 免费观看成人| 国产精品影片在线观看| 最新69国产成人精品视频免费| 国产精品久久久久aaaa樱花| 奶水喷射视频一区| 国产精品一区二区三区久久| 亚洲国产高清视频| 韩日成人av| 亚洲免费综合| 一本色道久久| 欧美成人一区二区在线 | 在线观看亚洲a| 亚洲网在线观看| 亚洲精品五月天| 久久福利精品| 久久成人18免费网站| 欧美日韩精品免费| 亚洲国产国产亚洲一二三| 黄色成人在线观看| 午夜精品www| 亚洲欧美日韩一区二区三区在线观看 | 午夜日韩福利| 欧美日韩少妇| 日韩午夜精品| 日韩天堂在线视频| 欧美黄色免费| 亚洲黄色天堂| 亚洲精品国产拍免费91在线| 久久亚洲一区二区| 美日韩在线观看| 黄色免费成人| 久久久久久久999精品视频| 久久精品99国产精品日本| 国产精品久久久久国产a级| 中文av字幕一区| 亚洲一区一卡| 国产精品久久午夜| 亚洲一区久久| 欧美在线日韩在线| 国产亚洲欧美一区二区三区| 欧美一区日本一区韩国一区| 久久精品观看| 尹人成人综合网| 蜜臀91精品一区二区三区| 欧美国产成人精品| 日韩视频在线观看国产| 欧美久久婷婷综合色| aa国产精品| 久久国产精品亚洲va麻豆| 国产亚洲精品激情久久| 久久久人成影片一区二区三区观看| 老妇喷水一区二区三区| 亚洲经典自拍| 国产精品成人aaaaa网站| 亚洲欧美bt| 免费人成网站在线观看欧美高清| 亚洲国产女人aaa毛片在线| 欧美国产一区二区三区激情无套| 亚洲精品中文字幕女同| 午夜精品久久久久久久久久久| 国产视频一区在线观看一区免费 | 欧美.www| 亚洲调教视频在线观看| 国产精品日韩在线观看| 久久久欧美一区二区| 亚洲日本在线视频观看| 欧美在线黄色| 亚洲久久一区| 国产九区一区在线| 免费亚洲电影在线| 亚洲香蕉伊综合在人在线视看| 久久精品夜色噜噜亚洲aⅴ| 亚洲精品免费网站| 国产精品一区二区三区成人| 麻豆精品视频在线| 亚洲欧美视频在线观看视频| 欧美成人精品激情在线观看| 亚洲专区在线视频| 亚洲国产日韩欧美| 国产免费一区二区三区香蕉精| 久热这里只精品99re8久| 一区二区三区国产在线| 免费观看成人www动漫视频| 午夜精品999| 亚洲精品美女在线| 一区二区三区在线免费观看| 欧美日韩一区二区视频在线| 久久伊人亚洲| 性久久久久久久久| 亚洲图片在区色| 91久久久国产精品| 欧美成人一品| 久久综合久久久| 欧美中文在线观看国产| 亚洲一二三区视频在线观看| 亚洲日本电影在线| 亚洲第一区在线| 国产一区二区三区久久悠悠色av| 国产精品进线69影院| 欧美精品videossex性护士| 久久夜色精品国产欧美乱极品| 亚洲在线国产日韩欧美| 日韩一区二区精品视频| 亚洲人体1000| 亚洲国产精品悠悠久久琪琪 | 一区二区三区www| 亚洲欧洲日夜超级视频| 亚洲二区在线视频| **性色生活片久久毛片| 国产一区二区三区在线播放免费观看| 欧美午夜宅男影院| 国产精品乱码妇女bbbb| 欧美性猛交xxxx乱大交蜜桃 | 久久精品中文字幕免费mv| 亚洲综合色噜噜狠狠| 亚洲欧美日韩久久精品| 先锋亚洲精品| 欧美在线视频一区| 久久香蕉国产线看观看av| 久久青草欧美一区二区三区| 久久久亚洲精品一区二区三区 | 欧美黄色一区二区| 欧美日韩mv| 国产精品v亚洲精品v日韩精品| 欧美视频日韩视频在线观看| 国产精品爱啪在线线免费观看| 国产精品久久久久一区| 国产日本欧洲亚洲| 精品1区2区3区4区| 亚洲免费不卡| 篠田优中文在线播放第一区| 久久精品三级| 亚洲国产成人av好男人在线观看| 亚洲丰满少妇videoshd| 99精品免费视频| 午夜精品福利电影| 久久久蜜桃精品| 欧美日韩国产欧美日美国产精品| 国产精品女人久久久久久| 精品成人a区在线观看| 亚洲精品人人| 午夜综合激情| 欧美承认网站| 中文在线一区| 久久一区中文字幕| 欧美婷婷久久| 亚洲成人原创| 午夜精品视频在线| 另类酷文…触手系列精品集v1小说| 欧美激情小视频| 亚洲欧美亚洲| 亚洲欧美视频一区| 久久久久久夜| 欧美日韩精品欧美日韩精品| 国产精品视频yy9099| 在线观看国产精品淫| 亚洲一区国产视频| 亚洲第一中文字幕| 午夜精品国产精品大乳美女| 欧美成人自拍视频| 国产亚洲一区精品| 亚洲一级免费视频| 欧美激情亚洲另类| 久久精品人人爽| 国产精品女同互慰在线看| 亚洲精品综合久久中文字幕| 久久精品国产96久久久香蕉| 99国产精品视频免费观看|