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

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 閱讀(436) 評論(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年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>
            国产午夜精品一区二区三区视频 | av成人手机在线| 你懂的视频欧美| 亚洲国产乱码最新视频| 欧美成人小视频| 欧美不卡视频一区| 最新日韩av| 日韩亚洲欧美一区二区三区| 欧美日韩国产在线播放网站| 亚洲视频第一页| 亚洲一区二区三区久久| 国产三级欧美三级| 免费看亚洲片| 欧美人在线观看| 校园春色综合网| 久久精品国产一区二区三区免费看| 国产一区二区三区在线观看视频| 久久伊人亚洲| 欧美日韩一区二区三区在线观看免| 亚洲一区二区三区免费在线观看| 亚洲直播在线一区| 亚洲高清毛片| 亚洲国产欧美在线人成| 日韩视频免费观看高清完整版| 国产精品久久久久国产a级| 欧美专区18| 欧美成人精品1314www| 亚洲男人的天堂在线观看| 久久av红桃一区二区小说| 日韩亚洲综合在线| 欧美一区网站| 一个色综合导航| 欧美在线亚洲| 亚洲一区二区三区精品动漫| 久久国内精品自在自线400部| 亚洲美女一区| 久久久亚洲精品一区二区三区 | 在线视频欧美精品| 欧美在线免费视屏| 亚洲视频一区二区免费在线观看| 欧美一区二区三区男人的天堂| 亚洲精品一区二区网址| 欧美一区二区三区四区在线| 99热免费精品| 久久久久久尹人网香蕉| 香蕉乱码成人久久天堂爱免费| 免费视频久久| 巨胸喷奶水www久久久免费动漫| 欧美日韩国产系列| 亚洲第一福利在线观看| 国产精品一区二区三区久久| 亚洲精品中文字幕在线观看| 亚洲福利小视频| 欧美伊人久久久久久午夜久久久久| 在线视频亚洲一区| 欧美福利电影网| 欧美.日韩.国产.一区.二区| 国产日韩1区| 亚洲一区三区电影在线观看| 中国亚洲黄色| 欧美日精品一区视频| 亚洲国产三级网| 亚洲精品一区二区三区四区高清| 久久成人精品视频| 久久美女性网| 在线播放中文字幕一区| 久久精品国产亚洲一区二区三区| 欧美在线一二三四区| 国产农村妇女毛片精品久久麻豆| 中文欧美在线视频| 亚洲自拍高清| 国产欧美亚洲精品| 午夜精品久久久久久99热软件| 羞羞色国产精品| 国产欧美丝祙| 久久黄金**| 欧美激情一区| 一本久久知道综合久久| 欧美日韩一区不卡| 亚洲一区精品视频| 久久精品国产亚洲aⅴ| 国模私拍一区二区三区| 久久久久久**毛片大全| 欧美高清不卡| 亚洲免费av网站| 国产精品电影在线观看| 中文国产一区| 国产裸体写真av一区二区| 久久黄金**| 亚洲三级免费电影| 亚洲欧美成人网| 国产一区二区三区视频在线观看| 久久九九有精品国产23| 亚洲国产一成人久久精品| 在线视频精品一区| 国产美女扒开尿口久久久| 久久视频在线视频| 亚洲精品男同| 久久久久久久网站| 日韩亚洲国产精品| 国产欧美午夜| 欧美久久九九| 久久成人一区| 一区二区不卡在线视频 午夜欧美不卡在 | 一区三区视频| 狠狠色综合网站久久久久久久| 欧美精品在线视频观看| 亚洲高清在线播放| 这里只有视频精品| 国产综合亚洲精品一区二| 久久综合999| 亚洲资源在线观看| 亚洲国产精品久久久久婷婷884| 亚洲女与黑人做爰| 亚洲二区在线| 欧美日韩国产精品成人| 中日韩视频在线观看| 欧美一区三区二区在线观看| 亚洲国产精品成人综合| 亚洲嫩草精品久久| 亚洲人成毛片在线播放| 国产日韩欧美视频在线| 欧美日韩国产综合网| 久久婷婷一区| 午夜宅男久久久| 一区二区黄色| 亚洲精品日韩一| 欧美高清在线精品一区| 久久精品一区四区| 午夜精品一区二区三区电影天堂 | 国产精品亚洲视频| 欧美日本免费| 欧美成人精品1314www| 久久九九精品| 久久精品综合| 欧美一区二区三区免费观看视频| 一区二区三区国产在线观看| 亚洲第一福利在线观看| 欧美a级在线| 免费人成精品欧美精品| 久久午夜精品一区二区| 久久噜噜噜精品国产亚洲综合| 欧美在线日韩| 久久www免费人成看片高清| 新狼窝色av性久久久久久| 亚洲自拍电影| 先锋亚洲精品| 久久高清国产| 久久久最新网址| 欧美成人免费网站| 亚洲国产精品va在线看黑人| 欧美激情精品久久久久| 国产视频欧美视频| 国产啪精品视频| 国内成+人亚洲+欧美+综合在线| 国产精品一区久久久| 国产酒店精品激情| 国产一区二区三区日韩欧美| 激情成人中文字幕| 亚洲级视频在线观看免费1级| 亚洲激情偷拍| 一区二区三欧美| 午夜老司机精品| 久久综合一区二区| 欧美国产视频在线| 亚洲九九九在线观看| 在线综合亚洲欧美在线视频| 亚洲一区二区在线观看视频| 欧美一区二区三区精品| 浪潮色综合久久天堂| 欧美精品日韩精品| 国产精品久久二区二区| 国产午夜亚洲精品理论片色戒| 狠狠久久亚洲欧美专区| 日韩亚洲综合在线| 欧美在线一区二区| 亚洲第一网站| 亚洲一区二区三区四区五区午夜 | 亚洲二区视频在线| 日韩亚洲一区二区| 欧美专区日韩视频| 欧美激情1区| 国产一级精品aaaaa看| 亚洲欧洲一区二区在线观看| 亚洲午夜黄色| 麻豆精品网站| 亚洲香蕉成视频在线观看| 久久免费偷拍视频| 国产精品欧美日韩一区| 亚洲韩日在线| 久久精品人人做人人爽电影蜜月| 欧美激情偷拍| 午夜在线精品| 欧美日韩在线三级| 亚洲欧洲精品天堂一级| 欧美资源在线| 9久草视频在线视频精品| 六月婷婷一区| 国内精品久久久久影院色| 亚洲亚洲精品三区日韩精品在线视频 |