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

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>
            亚洲区第一页| 国产精品国产精品国产专区不蜜| 西西裸体人体做爰大胆久久久| 欧美jizz19性欧美| 国产精品主播| 亚洲女女女同性video| 欧美国产高潮xxxx1819| 欧美亚洲在线| 国产农村妇女精品一二区| 亚洲男人天堂2024| 亚洲视频一区| 国产欧美日韩| 久久精品在线| 欧美一区二区三区在| 国产一区 二区 三区一级| 欧美亚洲色图校园春色| 亚洲淫片在线视频| 国产一区二区三区久久 | 久久精品国产成人| 亚洲永久在线| 国产一区二区三区四区五区美女 | 久久性天堂网| 91久久精品日日躁夜夜躁欧美| 欧美国产精品劲爆| 欧美精品首页| 欧美亚洲一区在线| 欧美一区二区成人6969| 亚洲国产三级网| 欧美一区二区成人| 中文精品在线| 日韩亚洲一区二区| 亚洲日本一区二区| 欧美精品一区二区久久婷婷| 99国产一区| 一区二区三区视频免费在线观看 | 亚洲国产精品成人| aa成人免费视频| 久久爱www| 亚洲在线中文字幕| 免费欧美在线视频| 亚洲欧美国产另类| 麻豆成人精品| 久久www成人_看片免费不卡| 欧美区在线播放| 亚洲精品在线观看视频| 久久久亚洲精品一区二区三区| 亚洲专区欧美专区| 亚洲自拍另类| 亚洲视频在线观看三级| 久久视频在线视频| 美玉足脚交一区二区三区图片| 国产精品免费电影| 亚洲伦理在线免费看| 亚洲国产精品久久久| 久久久蜜臀国产一区二区| 正在播放亚洲| 欧美乱人伦中文字幕在线| 裸体歌舞表演一区二区| 在线观看欧美| 欧美在线啊v| 欧美精品一区二区三区蜜臀| 欧美国产日韩视频| 一区二区三区日韩精品| 久久亚洲综合网| 久久夜色撩人精品| 亚洲成人资源网| 久久久久久9999| 欧美激情久久久| 99亚洲一区二区| 欧美日韩精品一区| 亚洲一区二区视频在线| 亚洲欧美一区二区三区久久 | 久久尤物视频| 亚洲高清视频一区| 欧美精品日韩www.p站| 亚洲高清在线精品| 在线一区免费观看| 欧美午夜精品一区| 欧美一级在线视频| 蜜臀久久99精品久久久画质超高清| 亚洲国产精品日韩| 欧美日韩国产一区二区| 欧美一区二区精品| 亚洲国产欧美日韩| 欧美一级日韩一级| 亚洲高清不卡一区| 欧美日韩亚洲一区| 久久久蜜桃精品| 在线一区二区三区四区| 久久综合色影院| 亚洲欧美中日韩| 亚洲国产精品一区二区久| 欧美视频在线观看| 欧美不卡视频一区发布| 亚洲欧美激情视频在线观看一区二区三区 | 久久久亚洲高清| 一区二区三区国产精华| 亚洲国产成人精品久久| 久久精品视频免费观看| 亚洲在线视频| 99精品欧美一区二区三区 | 久久亚洲精选| 久久精品视频免费观看| 亚洲新中文字幕| 一区二区精品国产| 亚洲人成免费| 亚洲精选久久| 亚洲黄网站黄| 亚洲国产精品久久人人爱蜜臀| 久久久久综合| 欧美成人xxx| 免费成人美女女| 欧美高清视频在线播放| 国产精品一区亚洲| 国产精品亚洲综合一区在线观看| 欧美日韩综合精品| 国产精品福利在线观看| 国产精品久久影院| 国产亚洲成av人在线观看导航| 国产酒店精品激情| 国产亚洲亚洲| 亚洲第一福利在线观看| 亚洲精品在线免费| 久久综合电影一区| 免费视频亚洲| 国产精品乱人伦中文| 国产欧美日韩免费看aⅴ视频| 一区二区三区我不卡| 久久成人免费视频| 亚洲欧美在线x视频| 久久精品夜色噜噜亚洲a∨| 久久久久久高潮国产精品视| 欧美电影美腿模特1979在线看| 欧美日产国产成人免费图片| 国产精品天天看| 黑人一区二区三区四区五区| 亚洲第一偷拍| 亚洲欧美日韩国产另类专区| 久久久亚洲国产美女国产盗摄| 最近看过的日韩成人| 一本色道久久综合亚洲精品高清| 亚洲线精品一区二区三区八戒| 性欧美大战久久久久久久久| 欧美成人小视频| 亚洲欧美卡通另类91av| 欧美国产亚洲精品久久久8v| 欧美性生交xxxxx久久久| 亚洲大胆av| 久久久久久久久久看片| 亚洲精品中文字幕在线| 久久综合中文| 国产综合色在线| 午夜精品福利视频| 亚洲精品护士| 麻豆免费精品视频| 激情欧美国产欧美| 久久成人综合视频| 亚洲综合激情| 国产精品每日更新| 亚洲综合精品自拍| 亚洲美女av在线播放| 欧美ed2k| 亚洲精品一二三| 亚洲人成久久| 欧美日韩三级在线| 亚洲网址在线| 午夜精品剧场| 经典三级久久| 欧美成人精品影院| 欧美好骚综合网| 亚洲素人在线| 亚洲免费视频一区二区| 狠狠色丁香久久婷婷综合_中| 久久综合给合久久狠狠色 | 在线一区二区三区四区五区| 亚洲美女视频网| 国产麻豆综合| 麻豆精品视频在线观看| 你懂的国产精品| 亚洲午夜黄色| 午夜在线精品偷拍| 亚洲国产清纯| 亚洲一区二区免费在线| 狠狠88综合久久久久综合网| 欧美激情一区二区三区在线视频| 欧美日韩午夜激情| 久久国产主播精品| 欧美精品九九| 久久精品人人做人人爽电影蜜月| 裸体女人亚洲精品一区| 午夜精品久久久久久久蜜桃app| 久久久久久亚洲精品中文字幕| 亚洲精品综合精品自拍| 欧美一二三区精品| 亚洲在线黄色| 免费成人高清| 免费成人av在线| 国产亚洲欧美日韩一区二区| 亚洲精品日韩久久| 91久久精品www人人做人人爽|