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

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);
}
}
}

  回復(fù)  更多評論   


只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


<2025年11月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

導(dǎo)航

統(tǒng)計

常用鏈接

留言簿(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>
            久久久精品网| 狠狠色噜噜狠狠狠狠色吗综合| 在线亚洲欧美专区二区| 亚洲日本电影| 欧美成人精品一区二区三区| 男男成人高潮片免费网站| 欧美一区二区视频在线观看| 亚洲福利免费| 亚洲人成网站色ww在线| 亚洲精品日韩在线观看| 亚洲最新合集| 香蕉成人久久| 久久先锋资源| 欧美性久久久| 狠狠干狠狠久久| 亚洲乱码一区二区| 亚洲一线二线三线久久久| 久久精品国产99精品国产亚洲性色 | 久久综合九色综合欧美就去吻| 免费影视亚洲| 一本一本久久| 老巨人导航500精品| 国产精品成人aaaaa网站| 黑人巨大精品欧美黑白配亚洲| 亚洲精品乱码久久久久久蜜桃麻豆| 亚洲欧美日韩综合| 欧美国产日本在线| 午夜日韩电影| 欧美日韩在线精品| 亚洲第一精品夜夜躁人人爽| 亚洲曰本av电影| 亚洲国产精品久久久| 亚洲欧美日韩综合国产aⅴ| 欧美激情第三页| 国产欧美三级| 欧美成黄导航| 国产色视频一区| 日韩亚洲一区二区| 美女精品国产| 性久久久久久久久久久久| 欧美人体xx| 亚洲精品在线免费观看视频| 久久久久久久久久久一区| 一区二区高清| 欧美日韩中文另类| 99精品国产在热久久| 欧美国产免费| 久久―日本道色综合久久| 国产乱人伦精品一区二区| 一卡二卡3卡四卡高清精品视频 | 99国产一区二区三精品乱码| 欧美 日韩 国产 一区| 亚洲欧美激情视频| 国产精品久久久久久久久| 一卡二卡3卡四卡高清精品视频| 欧美高清视频一区二区| 久久久久久久激情视频| 国产一区二区三区在线观看视频 | 亚洲国产高清视频| 久久欧美肥婆一二区| 欧美一区二区在线视频| 国产亚洲美州欧州综合国| 午夜精品福利视频| 亚洲综合三区| 国产一区日韩二区欧美三区| 久久久成人精品| 久久久久久精| 亚洲精品精选| 99国产精品久久久久久久久久 | 欧美日韩久久| 亚洲小视频在线| 亚洲在线中文字幕| 国产亚洲欧美另类中文| 麻豆精品视频在线| 欧美成人免费网站| 亚洲私人影吧| 性欧美大战久久久久久久免费观看| 国产一区二区三区在线观看免费视频| 久久精品视频免费| 久久亚洲精品中文字幕冲田杏梨| 91久久夜色精品国产网站| 亚洲精品一二三| 国产日韩欧美在线看| 欧美成人性网| 美女尤物久久精品| 国产欧美在线观看一区| 香蕉乱码成人久久天堂爱免费 | 性欧美18~19sex高清播放| 国产视频一区二区三区在线观看| 久久天堂国产精品| 欧美黄色一级视频| 欧美一区二区黄色| 免费的成人av| 西西人体一区二区| 久久人人97超碰国产公开结果 | 久久国产精品久久w女人spa| 欧美在线综合| 在线视频日韩| 久久国内精品视频| 99亚洲精品| 久久九九久精品国产免费直播| 亚洲人成亚洲人成在线观看| 亚洲一区在线看| 亚洲黄色免费网站| 午夜久久久久久久久久一区二区| 亚洲人成人一区二区三区| 亚洲欧美中文另类| 亚洲精品国精品久久99热一| 羞羞色国产精品| 艳妇臀荡乳欲伦亚洲一区| 欧美中文字幕在线| 亚洲特级片在线| 欧美xx69| 巨胸喷奶水www久久久免费动漫| 欧美涩涩网站| 亚洲欧洲在线观看| 一区二区视频在线观看| 亚洲一区欧美| 亚洲免费视频网站| 欧美日韩国产影片| 亚洲高清激情| 亚洲黄色在线观看| 久久久久久久久一区二区| 欧美在线视频免费播放| 欧美性做爰猛烈叫床潮| 亚洲精华国产欧美| 亚洲国产毛片完整版| 久久精品人人爽| 久久久综合免费视频| 国产午夜精品麻豆| 午夜影院日韩| 欧美在线视频二区| 国产一区观看| 欧美综合国产精品久久丁香| 久久精品动漫| 精品96久久久久久中文字幕无| 欧美制服第一页| 久久免费黄色| 1024亚洲| 欧美www视频| 亚洲精品一区在线| 亚洲网站啪啪| 国产精品美女一区二区| 国产精品日韩一区二区| 一区二区国产精品| 欧美精品在线一区二区三区| 欧美激情91| 亚洲人久久久| 欧美日本一区| 9人人澡人人爽人人精品| 亚洲综合精品四区| 国产麻豆精品theporn| 欧美一区二区三区免费观看| 久久米奇亚洲| 最新日韩在线视频| 欧美久久久久久| 亚洲视频一二区| 久久av一区二区三区亚洲| 国内精品一区二区| 欧美v国产在线一区二区三区| 亚洲国产成人在线播放| 亚洲视频一二| 中日韩男男gay无套| 久久久久99| 国产亚洲精品aa| 久久久五月婷婷| 另类av一区二区| 一本色道**综合亚洲精品蜜桃冫| 欧美日韩在线直播| 午夜精品视频在线观看| 免费短视频成人日韩| 亚洲卡通欧美制服中文| 国产精品乱码| 久久精品在这里| 亚洲精品一区久久久久久| 久久av资源网站| 99综合精品| 黑人巨大精品欧美黑白配亚洲| 欧美xart系列高清| 午夜精品免费在线| 91久久精品国产91久久性色tv| 亚洲在线中文字幕| 亚洲国产精品福利| 国产精一区二区三区| 欧美a级片网| 欧美有码在线视频| 99精品99久久久久久宅男| 久久久久久有精品国产| 在线一区亚洲| 亚洲精品1区| 国内精品久久久久影院 日本资源| 欧美国产精品v| 久久精品1区| 亚洲在线电影| 日韩亚洲欧美一区二区三区| 欧美大香线蕉线伊人久久国产精品| 午夜精品福利视频| 亚洲视频一区二区免费在线观看| 精品成人一区二区| 国产视频在线观看一区二区|