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

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>
            欧美午夜电影在线| 午夜精品久久久久久久久久久久久 | 欧美成人午夜| 国产欧美精品久久| 亚洲巨乳在线| 亚洲精选中文字幕| 久久久久久久999精品视频| 亚洲伊人伊色伊影伊综合网| 欧美丰满高潮xxxx喷水动漫| 久久中文字幕一区| 国产无一区二区| 亚洲深夜福利在线| 亚洲性色视频| 欧美精品一级| 亚洲激情在线观看视频免费| 国内成+人亚洲| 性久久久久久久久| 欧美综合二区| 国产欧美精品在线播放| 亚洲一区二区三区中文字幕| 亚洲综合另类| 国产精品久久久久av免费| 亚洲精品小视频在线观看| 日韩视频永久免费| 欧美激情精品久久久久久久变态| 欧美国产三区| 日韩网站在线看片你懂的| 欧美成人久久| 亚洲精品国产精品国自产在线 | 日韩亚洲综合在线| 欧美福利在线| 亚洲精品孕妇| 亚洲一区二区三区欧美| 国产精品视频yy9299一区| 亚洲综合三区| 久久精品人人爽| 亚洲成人在线免费| 欧美成人精品在线观看| 亚洲美女免费精品视频在线观看| 亚洲素人一区二区| 国产精品你懂的在线欣赏| 先锋影音网一区二区| 老司机67194精品线观看| 亚洲电影自拍| 欧美猛交免费看| 亚洲视频欧洲视频| 久久久99国产精品免费| 亚洲欧洲日本国产| 欧美午夜精品久久久久免费视| 亚洲欧美日韩精品久久奇米色影视| 久久精品国产91精品亚洲| 精品91视频| 欧美另类专区| 性做久久久久久久免费看| 欧美福利视频网站| 亚洲一区二区三区激情| 国产一区二区三区日韩| 麻豆成人综合网| 亚洲一区二区av电影| 裸体歌舞表演一区二区| 亚洲天堂免费在线观看视频| 国产在线播放一区二区三区| 欧美国产91| 欧美影院午夜播放| 亚洲每日更新| 免费av成人在线| 亚洲午夜免费视频| 亚洲国产精品高清久久久| 国产精品扒开腿做爽爽爽视频| 久久激情五月激情| 一区二区三区黄色| 欧美成人首页| 久久精品亚洲精品国产欧美kt∨| 日韩写真视频在线观看| 国产婷婷一区二区| 欧美视频四区| 欧美韩日高清| 久久嫩草精品久久久久| 亚洲欧美日本日韩| 妖精成人www高清在线观看| 老司机精品视频网站| 欧美亚洲一区二区三区| 99精品免费| 亚洲日韩欧美视频一区| 国模私拍视频一区| 欧美午夜无遮挡| 欧美日本精品在线| 你懂的国产精品| 久久国内精品视频| 亚洲欧美激情一区二区| 一区二区三区国产在线| 亚洲激情在线| 欧美激情在线免费观看| 美女亚洲精品| 久久久久网址| 久久九九全国免费精品观看| 亚洲欧美成人一区二区在线电影| 宅男精品导航| 亚洲一区二区高清| 99精品国产高清一区二区| 亚洲日本va午夜在线电影| 136国产福利精品导航网址应用| 国内精品国产成人| 国产一区白浆| 黄色在线一区| 怡红院av一区二区三区| 在线观看精品| 亚洲国产人成综合网站| 亚洲国产经典视频| 亚洲精品一区二区三区蜜桃久 | 一本色道久久综合狠狠躁篇怎么玩 | 欧美gay视频| 久久在精品线影院精品国产| 麻豆精品一区二区综合av| 免费观看在线综合| 欧美成人黑人xx视频免费观看| 欧美电影在线观看| 欧美日韩三级| 国产精品视频午夜| 国产人久久人人人人爽| 国产一区二区欧美日韩| 在线观看一区欧美| 亚洲精品一区二区三区四区高清| 日韩一级大片在线| 亚洲在线中文字幕| 久久不射中文字幕| 免费不卡在线观看| 亚洲日本成人| 亚洲欧美成人网| 久久精品欧洲| 欧美激情按摩在线| 国产精品午夜久久| 亚洲第一二三四五区| 一本色道久久加勒比88综合| 午夜在线精品| 欧美国产免费| 亚洲深夜福利| 久久综合伊人77777麻豆| 欧美精品一区二区三区一线天视频| 欧美系列亚洲系列| 激情久久五月天| 亚洲婷婷免费| 久久视频在线视频| 日韩午夜在线观看视频| 欧美亚洲三级| 欧美日本一区| 影音先锋成人资源站| 国产精品99久久久久久久久 | 99精品久久免费看蜜臀剧情介绍| 亚洲欧美日韩国产综合在线| 巨胸喷奶水www久久久免费动漫| 欧美视频中文字幕| 亚洲第一页在线| 午夜影视日本亚洲欧洲精品| 亚洲成人在线视频播放| 日韩一级网站| 久久久噜噜噜久噜久久 | 欧美日韩在线看| 亚洲二区免费| 欧美在线观看一区二区| 亚洲精品一区二区三区在线观看| 久久激五月天综合精品| 国产精品美女www爽爽爽| 亚洲国产精品一区二区www在线| 欧美一级艳片视频免费观看| 亚洲人成亚洲人成在线观看图片 | 亚洲女优在线| 欧美日韩成人在线观看| 在线观看亚洲精品视频| 欧美一级黄色录像| 一本在线高清不卡dvd| 欧美 亚欧 日韩视频在线| 国内精品久久久久久影视8| 亚洲综合色丁香婷婷六月图片| 欧美激情视频在线播放| 久久精品综合网| 国产啪精品视频| 香蕉乱码成人久久天堂爱免费 | 亚洲第一在线视频| 久久乐国产精品| 黄色精品一二区| 久久久久99精品国产片| 亚洲欧美成人网| 国产欧亚日韩视频| 欧美在线视频一区二区三区| 一区二区三区四区国产| 欧美日韩国产精品一区| 日韩天堂在线观看| 亚洲三级电影全部在线观看高清| 免费一级欧美片在线播放| 亚洲福利电影| 欧美激情中文不卡| 葵司免费一区二区三区四区五区| 一区二区三区在线高清| 免播放器亚洲一区| 久久久久久久综合色一本| 亚洲第一在线综合在线| 欧美国产极速在线| 欧美精品一区二区三区四区| 在线视频亚洲一区|