Welcome To SDIBT ACM-ICPC Online Judge

VIRTUAL JUDGE Recent Contest F.A.Qs Discuss Home ProblemSet Status Ranklist 13 Contest LoginRegister Exam
2017 ACM 集训队预选排名~      报名入口
Problem 1081. -- Slash Maze

Slash Maze

Time Limit: 1 Sec  Memory Limit: 64 MB
Submit: 4  Solved: 3
[Submit][Status][Discuss]

Description

By filling a rectangle with slashes (/) and backslashes ( \), you can generate nice little mazes. Here is an example: As you can see, paths in the maze cannot branch, so the whole maze contains only (1) cyclic paths and (2) paths entering somewhere and leaving somewhere else. We are only interested in the cycles. There are exactly two of them in our example. Your task is to write a program that counts the cycles and finds the length of the longest one. The length is defined as the number of small squares the cycle consists of (the ones bordered by gray lines in the picture). In this example, the long cycle has length 16 and the short one length 4.

Input

The input contains several maze descriptions. Each description begins with one line containing two integers w and h ( 1<=w, h<=75), representing the width and the height of the maze. The next h lines describe the maze itself and contain w characters each; all of these characters will be either ``/" or ``\". The input is terminated by a test case beginning with w = h = 0. This case should not be processed.

Output

For each maze, first output the line ``Maze #n:'', where n is the number of the maze. Then, output the line ``k Cycles; the longest has length l.'', where k is the number of cycles in the maze and l the length of the longest of the cycles. If the maze is acyclic, output ``There are no cycles." Output a blank line after each test case.

Sample Input

6 4
\//\\/
\///\/
//\\/\
\/\///
3 3
///
\//
\\\
0 0

Sample Output

Maze #1:
2 Cycles; the longest has length 16.

Maze #2:
There are no cycles.

HINT

Source

Mid-Central European Regional Contest 1999

[Submit][Status][Discuss]

HOME Back

한국어 中文 English
All Copyright Reserved 2008-2010 SDIBT TEAM
GPL2.0 2003-2010 HUSTOJ Project TEAM
Anything about the Problems, Please Contact Admin:admin