PipePuzzle
SRM 265 · 2005-09-27 · by HardCoder
Problem Statement
Given a
{"LL-L-",
"L+L+L",
"--NL-",
"L+--L",
"LL+L-"}
This is a graphical representation of the puzzle above.
Notes
- In each grid, south is the direction of increasing index within pipes, and north that of decreasing index. East is the direction of increasing index within an element of pipes, and west that of decreasing index.
Constraints
- pipes will have between 1 and 20 elements, inclusive.
- Each element of pipes will have length between 1 and 20, inclusive.
- Every element of pipes will have the same length.
- pipes will only contain the characters ('-', 'L', '+', 'N', 'S', 'E', 'W').
- pipes will have exactly one water source.
- pipes will contain between 0 and 20 elbow 'L' pipes, inclusive.
Statement by TopCoder, Inc. — view the original on the archive.
{"LL-L-",
"L+L+L",
"--NL-",
"L+--L",
"LL+L-"}
Returns: 19
{"ELLL",
"LLLL",
"LLLL",
"LLLL"}
Returns: 13
{"ELLLLL+",
"++++++L",
"L+++++L",
"L+++++L",
"L+++++L",
"L+++++L",
"+LLLLLL"}
Returns: 71
{"LLLLL",
"LLELL",
"LLLLL",
"LLLLL"}
Returns: 11
{"-+-+-+-+-+-+-+-+-+-W"}
Returns: 19
Submissions are judged against all 60 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class PipePuzzle with a public method int longest(vector<string> pipes) · 60 test cases · 2 s / 256 MB per case