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

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>
            欧美一级二区| 亚洲激情视频在线| 国产亚洲一区在线播放| 精品动漫3d一区二区三区免费版 | 亚洲精品久久久久中文字幕欢迎你| 亚洲第一狼人社区| 中文精品视频| 美女福利精品视频| 亚洲在线视频免费观看| 老色鬼精品视频在线观看播放| 国产精品红桃| 日韩一级片网址| 美女精品在线观看| 美女露胸一区二区三区| 国产一区999| 欧美freesex交免费视频| 亚洲天堂激情| 欧美三区在线观看| 亚洲免费成人| 欧美福利视频网站| 久久久在线视频| 国产一区二区三区免费在线观看| 狼人天天伊人久久| 欧美影院成人| 国产欧美一区二区精品仙草咪 | 欧美日韩亚洲一区二| 影音先锋日韩精品| 久久久久国产精品www| 亚洲图中文字幕| 国产资源精品在线观看| 久久精品99久久香蕉国产色戒| 亚洲视频在线看| 一色屋精品视频免费看| 亚洲免费av网站| 欧美日韩午夜剧场| 久久只精品国产| 久久成人人人人精品欧| 国内外成人免费视频| 亚洲资源av| 亚洲一区视频在线观看视频| 揄拍成人国产精品视频| 亚洲特级毛片| 亚洲精品一区久久久久久| 亚洲综合激情| 国精品一区二区| 一区二区欧美亚洲| 国产老肥熟一区二区三区| 欧美专区在线观看| 久久精品一二三区| 亚洲国产日韩一区二区| 亚洲欧美亚洲| 在线观看亚洲专区| 午夜精品三级视频福利| 黄色成人片子| 亚洲男人的天堂在线| 一本色道88久久加勒比精品| 99re亚洲国产精品| 亚洲精品免费在线| 亚洲一区成人| 亚洲一区二区在线免费观看| 美女黄色成人网| 欧美成人午夜视频| 好看的日韩视频| 亚洲欧美中文日韩在线| 性感少妇一区| 国产精品日日摸夜夜摸av| 久久蜜桃精品| 久久久久久国产精品mv| 欧美一区二区三区在线视频| 久久精品一本| 久久人人爽人人爽爽久久| 国产老肥熟一区二区三区| 亚洲小少妇裸体bbw| 亚洲夜间福利| 久久免费午夜影院| 亚洲欧美一区二区三区在线 | 亚洲高清免费| 国产精品一区在线观看| 亚洲女性裸体视频| 性欧美暴力猛交另类hd| 国产精品激情电影| 午夜精品影院在线观看| 久久精品2019中文字幕| 国内精品久久久久影院薰衣草| 欧美亚洲一区二区三区| av成人免费| 欧美系列一区| 亚洲日韩欧美视频| 亚洲最新中文字幕| 国产精品免费视频观看| 亚洲欧洲午夜| 亚洲大黄网站| 欧美日韩视频专区在线播放| 一区二区三区产品免费精品久久75| 午夜欧美视频| 亚洲国产高清在线观看视频| 性欧美videos另类喷潮| 噜噜噜91成人网| 亚洲理论在线| 国产乱码精品一区二区三区忘忧草 | 久久久久久久综合狠狠综合| 激情小说亚洲一区| 欧美成人激情视频| 美女诱惑黄网站一区| 亚洲精品一区久久久久久| 欧美吻胸吃奶大尺度电影| 欧美亚洲综合网| 亚洲欧洲日本专区| 欧美影院成人| 亚洲激情成人网| 国产女人水真多18毛片18精品视频| 久久精品视频亚洲| 99精品国产热久久91蜜凸| 亚洲精品在线电影| 国产精品嫩草99av在线| 免费日本视频一区| 亚洲高清一二三区| 欧美中文在线字幕| 日韩一级免费观看| 又紧又大又爽精品一区二区| 国产精品二区在线| 欧美国产成人精品| 日韩亚洲欧美精品| 久久中文精品| 欧美综合国产精品久久丁香| 亚洲国产91精品在线观看| 国产伦一区二区三区色一情| 欧美国产日韩一区二区| 久久免费高清| 先锋影音久久久| 中国日韩欧美久久久久久久久| 亚洲欧美国产不卡| 国产精品一区免费视频| 欧美日韩国产a| 亚洲欧美一区二区三区久久 | 午夜天堂精品久久久久 | 欧美日韩在线一二三| 久久一二三国产| 久久精品国产第一区二区三区最新章节 | 亚洲女性裸体视频| 一二三四社区欧美黄| 亚洲精品美女久久久久| 亚洲国产美女| 亚洲黄色三级| 亚洲国产精品第一区二区三区| 韩日精品在线| 国产一区二区欧美日韩| 国产色综合久久| 蜜桃久久精品乱码一区二区| 久久久精品999| 久久久国际精品| 久久深夜福利免费观看| 久久久久国产精品一区二区| 久久激情久久| 久久国产精品久久久久久久久久 | 亚洲免费一在线| 亚洲欧美日韩电影| 欧美亚洲免费| 久久九九久精品国产免费直播| 欧美一区视频| 久久一区国产| 欧美另类一区| 久久精彩免费视频| 可以免费看不卡的av网站| 欧美3dxxxxhd| 欧美日韩在线电影| 国产精品一区=区| 精品99一区二区三区| 在线日韩一区二区| 一区二区国产日产| 亚洲国产精品嫩草影院| 亚洲精选大片| 午夜在线精品偷拍| 久久久久久综合网天天| 欧美国产精品va在线观看| 日韩亚洲视频| 欧美在线在线| 欧美精品七区| 欧美日韩成人网| 国产精品夜夜夜| 亚洲激情精品| 午夜一区不卡| 欧美激情欧美激情在线五月| 久久综合九色综合网站| 亚洲精品在线观| 亚洲黄色免费| 欧美国产欧美亚洲国产日韩mv天天看完整 | 夜夜嗨av一区二区三区四区| 日韩午夜高潮| 久久av一区| 欧美亚男人的天堂| 在线看不卡av| 午夜影视日本亚洲欧洲精品| 欧美福利视频一区| 亚洲欧美日韩另类精品一区二区三区| 久久天堂av综合合色| 国产精品久久久久久妇女6080 | 欧美日韩国产va另类| 国内精品亚洲| 午夜国产精品视频|