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

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 閱讀(421) 評論(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);
}
}
}

  回復  更多評論   

<2007年11月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

導航

統計

常用鏈接

留言簿(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>
            欧美黄色小视频| 久久久久久久久蜜桃| 亚洲精品欧美| 欧美视频在线观看视频极品| 亚洲欧美日本国产有色| 午夜日韩在线观看| 精品成人国产| 亚洲欧洲在线播放| 国产精品伦一区| 久久一区国产| 欧美日韩极品在线观看一区| 亚洲综合三区| 久久久www免费人成黑人精品| 91久久久久久| 午夜精品影院| 亚洲欧洲免费视频| 亚洲欧美激情视频在线观看一区二区三区| 狠狠色狠狠色综合日日五| 亚洲国产成人在线视频| 国产精品一区三区| 亚洲国产精品激情在线观看| 国产精品视频一| 亚洲激情电影中文字幕| 国产亚洲激情| 亚洲精品一区二区三区在线观看| 国产女精品视频网站免费| 亚洲二区在线观看| 国产偷自视频区视频一区二区| 亚洲大片免费看| 国产视频一区在线观看| 亚洲精品中文字幕在线| 精品成人国产| 亚洲免费一在线| 一本色道久久综合亚洲精品不| 欧美在线免费视屏| 亚洲欧美日韩区| 欧美激情精品久久久久久黑人| 久久精品一区蜜桃臀影院| 欧美日一区二区在线观看| 免费在线看成人av| 国产三级欧美三级| 亚洲一区在线免费观看| 日韩一区二区福利| 欧美成人精品h版在线观看| 久久久精品tv| 国产午夜精品一区理论片飘花| 99精品福利视频| 日韩小视频在线观看| 美脚丝袜一区二区三区在线观看 | 亚洲精品老司机| 久久九九免费视频| 久久精品二区三区| 国产日韩一区二区三区在线播放 | 欧美电影免费观看| 在线观看精品| 久久综合激情| 欧美成人亚洲成人日韩成人| 激情久久影院| 久久偷看各类wc女厕嘘嘘偷窃| 欧美在线免费视频| 国产精品视频网站| 欧美亚洲在线| 久久久久久久综合日本| 国产无一区二区| 欧美一区二区三区男人的天堂| 欧美在线观看一区二区| 国产日韩欧美视频| 久久黄色影院| 欧美承认网站| 99精品国产福利在线观看免费| 欧美日韩国产成人精品| 国产精品99久久久久久人| 亚洲自拍偷拍网址| 国产一区二区三区日韩欧美| 久久精品九九| 亚洲激情网站免费观看| 中国成人黄色视屏| 国产精品自拍网站| 久久亚洲不卡| 99国产精品视频免费观看一公开| 亚洲一区在线免费| 国语自产精品视频在线看一大j8| 久久久国产成人精品| 亚洲第一区色| 亚洲一区二区三区色| 国产一区二区三区免费在线观看| 久久精品成人一区二区三区| 亚洲国产三级网| 亚洲网址在线| 在线不卡中文字幕播放| 欧美精品九九| 亚洲综合社区| 亚洲国产精品福利| 久久激情视频久久| 日韩一级精品| 激情久久五月| 国产精品v日韩精品| 久久久久九九九| 一区二区欧美在线| 免费在线观看一区二区| 亚洲欧美激情一区二区| 亚洲电影免费观看高清完整版在线观看 | 亚洲伦理一区| 国产原创一区二区| 欧美喷潮久久久xxxxx| 久久xxxx| 99在线热播精品免费99热| 久久免费国产精品| 亚洲自拍偷拍一区| 亚洲精品乱码久久久久久| 国产欧美一区二区精品仙草咪| 牛夜精品久久久久久久99黑人| 亚洲中无吗在线| 亚洲美女中文字幕| 欧美成人精品在线观看| 久久成人精品| 亚洲一区二区三区在线视频| 亚洲福利久久| 激情六月婷婷久久| 国产日韩精品电影| 国产精品免费观看视频| 欧美区视频在线观看| 男女精品视频| 久久免费精品视频| 欧美中文字幕视频在线观看| 正在播放欧美视频| 一区二区三区四区国产| 91久久精品国产91性色| 欧美 日韩 国产 一区| 久久久一本精品99久久精品66| 亚洲欧美日韩精品久久亚洲区| 亚洲天天影视| 亚洲五月婷婷| 亚洲图片欧美日产| 中文国产一区| 欧美在线播放视频| 欧美专区一区二区三区| 午夜精品久久久久久久99黑人| 一本久久青青| 亚洲小说欧美另类社区| 亚洲一区二区三区在线播放| 中文国产一区| 亚洲欧美另类中文字幕| 亚洲一区www| 亚洲欧美精品suv| 欧美制服丝袜第一页| 久久国产主播精品| 麻豆成人在线观看| 欧美精品久久久久久久| 欧美四级在线观看| 国产日产精品一区二区三区四区的观看方式 | 亚洲日韩欧美视频一区| 亚洲精品黄色| 亚洲一区二区三区在线看 | 亚洲女性裸体视频| 欧美一站二站| 免费国产一区二区| 欧美日本视频在线| 国产精品私拍pans大尺度在线| 国产日韩欧美在线一区| 在线国产日韩| 亚洲图片在线| 久久美女性网| 亚洲国产一区二区在线| 日韩午夜在线视频| 欧美一区二区国产| 欧美激情亚洲| 国产日韩av高清| 亚洲黄色影院| 欧美一区二区在线免费观看| 免费不卡亚洲欧美| 一区二区三区高清在线观看| 欧美一区二区黄色| 欧美另类变人与禽xxxxx| 国产精品人人做人人爽| 亚洲大胆av| 午夜亚洲视频| 欧美激情精品久久久久久大尺度| 99riav久久精品riav| 久久久久久久国产| 国产精品福利在线观看网址| 狠狠久久综合婷婷不卡| 亚洲小少妇裸体bbw| 欧美sm重口味系列视频在线观看| 一本色道久久综合亚洲精品不卡| 久久爱www.| 国产精品网曝门| 99精品99| 欧美不卡一区| 午夜精品在线| 欧美日韩视频| 亚洲人成在线影院| 久久亚洲一区二区| 亚洲欧美清纯在线制服| 欧美激情视频网站| 亚洲二区视频在线| 久久久国产一区二区三区| 亚洲一区二区三| 国产精品s色| 这里只有精品视频|