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

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>
            欧美黑人国产人伦爽爽爽| 欧美理论电影在线播放| 国产日韩欧美亚洲| 久久av资源网站| 久久成年人视频| 一区二区三区在线视频观看| 久久综合九色综合网站| 玖玖综合伊人| av成人国产| 中国日韩欧美久久久久久久久| 欧美色网在线| 久久精品女人| 欧美成人国产va精品日本一级| 日韩一级网站| 亚洲欧美在线一区| 在线看片一区| 国产视频久久久久| 另类亚洲自拍| 欧美精品自拍偷拍动漫精品| 午夜久久一区| 欧美69wwwcom| 欧美一区二区三区成人 | 亚洲裸体在线观看| 在线一区二区日韩| 极品少妇一区二区三区| 亚洲黄色影院| 国产精品日韩欧美一区| 另类春色校园亚洲| 国产精品扒开腿做爽爽爽视频 | 亚洲欧美国产高清va在线播| 亚洲欧美日韩国产| 亚洲全黄一级网站| 亚洲综合99| 亚洲乱码国产乱码精品精98午夜| 亚洲一区中文| 日韩性生活视频| 欧美一区二区三区四区高清 | 激情久久久久久久久久久久久久久久 | 欧美电影美腿模特1979在线看| 亚洲欧美日韩一区在线| 蜜臀av在线播放一区二区三区| 亚洲免费在线观看视频| 欧美α欧美αv大片| 久久久一本精品99久久精品66| 欧美日产一区二区三区在线观看| 裸体女人亚洲精品一区| 国产精品久久久久影院色老大| 亚洲成色777777在线观看影院 | 欧美一区二区视频在线观看2020| 99re热这里只有精品免费视频| 久久国产精品99久久久久久老狼| 亚洲一区精品电影| 欧美精品久久久久a| 欧美 日韩 国产 一区| 国产午夜精品久久久| aa级大片欧美三级| 9色国产精品| 欧美大片在线观看| 欧美激情一区二区三区在线视频观看| 国产亚洲人成网站在线观看| 国产精品99久久久久久久久| 在线亚洲欧美视频| 欧美精品18| 亚洲精品免费电影| 亚洲精品一区二区三区福利| 免费在线国产精品| 欧美黄色免费网站| 亚洲区在线播放| 你懂的网址国产 欧美| 欧美激情1区2区3区| 亚洲区欧美区| 欧美另类视频| 国产在线播精品第三| 午夜亚洲性色福利视频| 久久久久国产免费免费| 国产自产精品| 久久青草欧美一区二区三区| 老司机久久99久久精品播放免费| 国产偷国产偷亚洲高清97cao| 性久久久久久| 久久亚洲图片| 亚洲精选视频在线| 欧美日韩一区二区在线播放| 中文精品视频一区二区在线观看| 午夜日韩视频| 黄色成人在线免费| 欧美刺激性大交免费视频 | 宅男噜噜噜66国产日韩在线观看| 欧美无乱码久久久免费午夜一区| 亚洲午夜伦理| 久久久久久国产精品一区| 亚洲福利视频二区| 欧美裸体一区二区三区| 亚洲欧美成人| 欧美福利精品| 亚洲性视频网站| 国产综合网站| 欧美精品少妇一区二区三区| 亚洲夜晚福利在线观看| 免费日本视频一区| 亚洲一级二级| 亚洲高清不卡在线| 国产精品高潮呻吟视频| 久久国产一区| 99在线|亚洲一区二区| 久久精品在这里| 一区二区三区高清视频在线观看| 国产欧美精品| 欧美精品日韩一本| 久久精品国产99国产精品澳门| 亚洲精品日韩精品| 久久影视三级福利片| 亚洲香蕉网站| 亚洲精品美女久久7777777| 国产精品一区=区| 亚洲福利视频专区| 国产主播一区二区三区四区| 欧美激情91| 久久av一区二区| 亚洲一区二区三区四区五区黄| 欧美激情亚洲国产| 久久久久久久性| 香港成人在线视频| 亚洲视频观看| 亚洲日本理论电影| 曰韩精品一区二区| 国产亚洲美州欧州综合国| 欧美午夜在线一二页| 欧美国产日本韩| 噜噜噜在线观看免费视频日韩| 性欧美video另类hd性玩具| 99re成人精品视频| 亚洲人屁股眼子交8| 欧美激情bt| 欧美刺激午夜性久久久久久久| 久久久91精品国产一区二区精品| 亚洲一区二区三区久久 | 欧美高清不卡| 猫咪成人在线观看| 久久五月激情| 久久九九精品| 亚洲人成在线播放网站岛国| 亚洲成色777777女色窝| 韩国av一区二区| 国产主播精品| 韩国一区二区在线观看| 国产一区二区中文| 精品福利电影| 影音欧美亚洲| 91久久精品国产91久久| 亚洲三级国产| 日韩一区二区精品| 亚洲视频网站在线观看| 亚洲一区二区免费| 欧美一区二区女人| 久久精品国产综合| 美日韩在线观看| 欧美国产欧美亚洲国产日韩mv天天看完整| 久久婷婷成人综合色| 欧美不卡一区| 亚洲精品自在久久| 亚洲一区二区在线观看视频| 亚洲男人的天堂在线观看| 欧美一区二区黄色| 久久婷婷色综合| 欧美激情综合五月色丁香| 欧美视频日韩视频| 国产性天天综合网| 亚洲欧洲午夜| 亚洲欧美日韩精品久久亚洲区 | 欧美a级一区二区| 亚洲人www| 亚洲婷婷综合久久一本伊一区| 午夜精品国产更新| 另类综合日韩欧美亚洲| 欧美日韩一区二区三| 国产日韩欧美另类| 亚洲精品日日夜夜| 亚洲欧美色婷婷| 欧美岛国在线观看| 亚洲小视频在线观看| 另类av一区二区| 国产精品综合| 亚洲理论在线观看| 久久精品五月婷婷| 亚洲精品视频在线播放| 性欧美18~19sex高清播放| 欧美激情精品久久久| 国产欧美一区二区三区国产幕精品| 亚洲盗摄视频| 欧美亚洲色图校园春色| 亚洲激情另类| 久久精品亚洲一区| 欧美午夜美女看片| 91久久极品少妇xxxxⅹ软件| 久久国产主播| 妖精视频成人观看www| 免费不卡视频| 狠狠色综合一区二区| 香蕉国产精品偷在线观看不卡|