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

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) 評(píng)論(1)  編輯 收藏 引用

評(píng)論

# 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ù)  更多評(píng)論   


只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


<2025年9月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

留言簿(1)

隨筆檔案

搜索

最新評(píng)論

閱讀排行榜

評(píng)論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲欧美日韩一区在线观看| 久久成人免费| 美女任你摸久久| 亚洲国产另类久久精品| 欧美阿v一级看视频| 麻豆av一区二区三区| 亚洲人成高清| 亚洲视频在线一区观看| 国产偷国产偷亚洲高清97cao| 久久字幕精品一区| 欧美电影专区| 欧美本精品男人aⅴ天堂| 亚洲欧美日韩另类| 精品99视频| 亚洲视频你懂的| 亚洲一区三区视频在线观看| 国产一区二区三区无遮挡| 老司机免费视频一区二区| 欧美电影免费网站| 性欧美18~19sex高清播放| 久久精品网址| 亚洲欧美精品| 久热这里只精品99re8久| 亚洲一区二区三区在线播放| 欧美制服第一页| 亚洲无玛一区| 牛夜精品久久久久久久99黑人 | 亚洲黄色影院| 国产精品亚洲综合色区韩国| 久久久久久香蕉网| 欧美大胆成人| 免费欧美日韩国产三级电影| 亚洲网站视频福利| 麻豆精品在线视频| 欧美一区永久视频免费观看| 欧美大片在线看免费观看| 久久精品91久久久久久再现| 欧美日韩一二区| 老牛影视一区二区三区| 国产精品日本| 一区二区三区波多野结衣在线观看| 亚洲电影激情视频网站| 午夜在线播放视频欧美| 亚洲午夜视频在线观看| 欧美激情1区2区3区| 欧美黄色一区| 在线观看亚洲专区| 久久精品国产一区二区三| 亚洲自拍偷拍色片视频| 欧美女同在线视频| 亚洲黄页一区| 91久久国产自产拍夜夜嗨| 久久精品亚洲乱码伦伦中文| 久久国产手机看片| 国产精品欧美日韩| 亚洲深爱激情| 亚洲欧美在线高清| 国产精品欧美一区二区三区奶水| 亚洲精品一区二区三区婷婷月| 亚洲电影欧美电影有声小说| 久久精品在线播放| 老司机一区二区三区| 国产一区在线观看视频| 欧美一区二区成人| 久久9热精品视频| 国产精品久久久久久久久久免费看 | 亚洲人成7777| 欧美激情国产精品| 亚洲欧洲偷拍精品| 日韩视频免费看| 欧美人妖在线观看| 亚洲狠狠婷婷| 亚洲五月婷婷| 欧美日韩国产精品自在自线| 亚洲成色www8888| 99亚洲精品| 国产精品jizz在线观看美国| 亚洲欧美久久久| 久久久久久一区二区三区| 国产一区在线免费观看| 久久久五月天| 亚洲人成人一区二区在线观看| 亚洲美女福利视频网站| 欧美日韩视频在线第一区| 亚洲已满18点击进入久久| 久久精品天堂| 亚洲黄色小视频| 国产精品电影在线观看| 欧美一区二区| 亚洲电影视频在线| 一区二区三区产品免费精品久久75 | 亚洲一区二区少妇| 国产精品亚洲美女av网站| 欧美在线亚洲综合一区| 欧美黄色一区| 亚洲欧美不卡| 亚洲精品在线一区二区| 国产精品美女一区二区在线观看| 欧美一区二区在线免费观看| 欧美黑人多人双交| 欧美一级免费视频| 亚洲激情亚洲| 国产欧美日韩精品丝袜高跟鞋 | 久热综合在线亚洲精品| 日韩一级裸体免费视频| 久久久噜噜噜久久久| 99精品视频免费观看| 国产女优一区| 欧美理论在线| 久久久久久久一区| 亚洲午夜在线视频| 亚洲电影在线观看| 久久久久久久一区| 国产精品女人毛片| 黄色另类av| 国内成人精品2018免费看| 欧美成人免费全部观看天天性色| 中文无字幕一区二区三区| 欧美成人免费网| 欧美在线视频免费观看| 99视频+国产日韩欧美| 一区在线视频观看| 国产日韩欧美视频| 欧美婷婷久久| 欧美日本国产一区| 久久亚洲欧洲| 欧美在线观看www| 亚洲自拍电影| 亚洲深夜福利| 一区二区毛片| 99热这里只有成人精品国产| 亚洲电影免费在线| 欧美+日本+国产+在线a∨观看| 久久国产精品久久久久久电车 | 国产精品xxxxx| 性欧美video另类hd性玩具| 亚洲一区二三| 午夜视频在线观看一区二区三区| 亚洲国产一成人久久精品| 国产女人水真多18毛片18精品视频| 欧美日韩和欧美的一区二区| 欧美电影免费观看| 欧美成人一区二区三区在线观看 | 久久99伊人| 欧美一区二区三区免费在线看| 亚洲小少妇裸体bbw| 一区二区三区久久久| 亚洲素人在线| 午夜电影亚洲| 欧美在线free| 久久久久久久久一区二区| 久久久久久高潮国产精品视| 久久亚洲一区二区三区四区| 久久婷婷亚洲| 欧美激情第3页| 最新国产の精品合集bt伙计| 亚洲日本aⅴ片在线观看香蕉| 91久久久在线| 亚洲日本在线观看| 日韩视频一区| aa级大片欧美| 亚洲欧美另类在线观看| 亚洲欧美视频一区二区三区| 久久精品欧美| 欧美精品在线观看91| 欧美午夜不卡在线观看免费| 国产精品美女主播| 国内一区二区三区在线视频| 亚洲国产精品成人久久综合一区| 亚洲欧洲精品一区二区三区| 亚洲视频在线观看| 久久九九久久九九| 欧美电影免费观看高清| 亚洲美女福利视频网站| 午夜精品影院在线观看| 欧美aa国产视频| 国产精品剧情在线亚洲| 狠狠色伊人亚洲综合网站色| 亚洲乱码久久| 久久精品一区二区三区不卡牛牛| 免费观看一区| 亚洲一区二区在线免费观看| 麻豆av一区二区三区| 国产精品久久久久影院亚瑟 | 久久激情视频| 欧美体内she精视频在线观看| 一区二区三区在线不卡| 这里只有精品丝袜| 免费短视频成人日韩| 99视频在线观看一区三区| 久久久福利视频| 国产精品美女久久久| 亚洲国产精品久久久久| 欧美专区亚洲专区| 亚洲精品一品区二品区三品区| 久久精品国产久精国产一老狼| 欧美天天影院| 一本一道久久综合狠狠老精东影业| 久久精品亚洲一区| 亚洲视频一起|