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

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>
            亚洲中字在线| 一区二区三区四区在线| 欧美一区国产二区| 国产一区二区三区高清播放| 小辣椒精品导航| 午夜在线a亚洲v天堂网2018| 国产精品一区在线观看| 亚洲欧美影音先锋| 欧美亚洲色图校园春色| 韩曰欧美视频免费观看| 女人色偷偷aa久久天堂| 欧美成人福利视频| 亚洲性视频网站| 亚洲欧美日韩视频二区| 黄色亚洲免费| 亚洲激情欧美激情| 欧美日韩免费精品| 欧美在线播放一区二区| 欧美亚洲一区二区在线观看| 亚洲欧美日韩综合| 在线看视频不卡| 亚洲黄色在线| 国产精品一区二区男女羞羞无遮挡 | 欧美国产日韩一区| 亚洲在线一区二区三区| 国内外成人免费视频 | 亚洲人成亚洲人成在线观看图片| 亚洲国产导航| 国产精品男gay被猛男狂揉视频| 久久大综合网| 欧美啪啪成人vr| 久久狠狠亚洲综合| 欧美激情一区二区三区在线| 午夜精品久久久久久久99樱桃 | 亚洲欧美日韩国产综合在线| 在线播放一区| 在线亚洲电影| 在线观看精品视频| 亚洲欧美经典视频| 一个人看的www久久| 久久精品国产99| 亚洲欧美在线免费观看| 免费欧美在线视频| 久久精彩免费视频| 国产精品电影在线观看| 欧美福利视频一区| 免播放器亚洲| 久久久久九九视频| 国产精品v日韩精品| 欧美福利电影在线观看| 国产性天天综合网| 一本色道久久| 一本色道久久综合狠狠躁篇怎么玩 | 免费看黄裸体一级大秀欧美| 国产精品日韩欧美一区二区| 亚洲精品久久久久| 亚洲国产精品ⅴa在线观看| 性欧美办公室18xxxxhd| 亚洲夜间福利| 欧美三级电影精品| 亚洲日本久久| 99亚洲视频| 欧美大秀在线观看| 亚洲国产高清在线观看视频| 在线观看亚洲| 久久青青草综合| 久热精品视频在线| 狠狠色狠狠色综合日日tαg| 性视频1819p久久| 久久精品男女| 国内精品视频久久| 久久久久综合一区二区三区| 久久免费精品日本久久中文字幕| 国产日产高清欧美一区二区三区| 亚洲一区二区三区免费观看| 亚洲一区二区在线观看视频| 欧美三级午夜理伦三级中文幕| 日韩一区二区精品| 亚洲免费视频中文字幕| 国产精品毛片a∨一区二区三区| 亚洲深爱激情| 久久精品二区| 亚洲高清在线观看| 欧美高清你懂得| 夜夜爽99久久国产综合精品女不卡| 99视频精品全部免费在线| 欧美人妖另类| 亚洲视频免费在线观看| 欧美一区日韩一区| 激情久久五月天| 欧美激情精品久久久久| 中日韩高清电影网| 久久激情五月婷婷| 亚洲国产欧美日韩| 欧美视频在线观看一区| 亚洲女爱视频在线| 欧美成人在线网站| 亚洲性线免费观看视频成熟| 国产乱人伦精品一区二区| 久久久精品免费视频| 亚洲国产精品激情在线观看| 亚洲一区精品视频| 国产在线精品二区| 欧美不卡高清| 午夜天堂精品久久久久| 欧美激情小视频| 午夜精品区一区二区三| 亚洲国产精品va在线看黑人动漫| 欧美裸体一区二区三区| 久久超碰97人人做人人爱| 亚洲国产精品va| 欧美在线观看一区二区| 亚洲精品视频在线| 国产综合在线看| 欧美人与禽性xxxxx杂性| 久久国产精品久久精品国产| 日韩小视频在线观看专区| 久久久久久欧美| 亚洲在线1234| 亚洲国产日韩欧美在线99| 国产麻豆午夜三级精品| 欧美日本簧片| 免费在线播放第一区高清av| 欧美一区二区三区免费视| 99精品黄色片免费大全| 亚洲国产毛片完整版| 久久久久久久高潮| 亚洲免费在线观看视频| 99精品视频免费观看视频| 尤物精品在线| 国产一区二区三区不卡在线观看| 欧美午夜不卡在线观看免费 | 国产精品青草久久| 欧美精品不卡| 欧美ab在线视频| 久久婷婷人人澡人人喊人人爽| 亚洲欧美国产不卡| 亚洲视频网站在线观看| 亚洲乱码一区二区| 亚洲日本中文字幕区| 欧美成人视屏| 欧美粗暴jizz性欧美20| 久久久蜜桃一区二区人| 久久久成人网| 久久野战av| 久久青草欧美一区二区三区| 久久精品国产第一区二区三区最新章节 | 久久网站免费| 久久性色av| 葵司免费一区二区三区四区五区| 久久成人精品电影| 久久精品一区二区三区四区| 久久成人免费电影| 久久久噜噜噜久久久| 免费在线国产精品| 欧美成人资源网| 欧美精品免费在线| 欧美日韩高清在线观看| 欧美三级网页| 国产精品欧美激情| 国产精品一区二区男女羞羞无遮挡| 国产精品免费视频观看| 国产欧美一区视频| 在线精品视频一区二区三四| 91久久久国产精品| 日韩午夜在线播放| 午夜精品久久久久久久久久久久| 欧美一级夜夜爽| 农村妇女精品| 亚洲精品在线电影| 亚洲欧美综合精品久久成人 | 亚洲精品一区二区网址| 一区二区日本视频| 香蕉亚洲视频| 欧美成人免费播放| 国产精品乱码人人做人人爱| 韩日视频一区| av成人免费在线观看| 欧美综合二区| 亚洲第一区在线观看| 亚洲午夜精品网| 久久精视频免费在线久久完整在线看| 久久久xxx| 国产精品白丝黑袜喷水久久久| 国产在线日韩| 一二三区精品| 麻豆精品在线视频| 这里只有精品视频| 久久夜色精品一区| 国产精品推荐精品| 亚洲人成久久| 久久精品国产999大香线蕉| 亚洲观看高清完整版在线观看| 亚洲一级黄色| 欧美精品九九99久久| 黑人一区二区| 欧美一区2区三区4区公司二百| 亚洲国产成人91精品| 欧美一区二区三区四区视频| 欧美日韩国内|