EncloseArea
SRM 776 · 2020-01-23 · by misof
Problem Statement
You can order a custom rectangular chessboard. Both the number of rows and the number of columns must be between 1 and 50, inclusive.
You have a sufficient supply of walls. Each wall exactly fits onto a diagonal of a cell of the chessboard. Your task is to place some of these walls onto some of the diagonals of your chessboard cells in such a way that:
- The walls form a single continuous boundary of a region of the chessboard.
- The area of that region is exactly A.
Return a
Notes
- The boundary of the region enclosed by the walls must not touch or intersect itself, and it may not branch anywhere. In other words, each endpoint of each wall must touch exactly one other wall, and there must be just one connected component of walls.
- The returned String[] must describe a rectangular chessboard. I.e., all elements of the return value must have the same length.
Constraints
- A will be between 1 and 2500, inclusive.
12
Returns: {"........", "../\\....", "./..\\...", ".\\...\\..", "..\\../..", "...\\/...", "........", "........" }
Note that the backslashes in the example output are escaped, i.e., each backslash is shown as \\ Below we show a nicer formatting of the return value: ........ ../\.... ./..\... .\...\.. ..\../.. ...\/... ........ ........
7
Returns: { }
It is not possible to enclose a region with area 7.
2498
Returns: { }
It is also impossible to enclose a region with area 2498. Remember the constraints on the chessboard size.
10
Returns: {"./\\..", "/./..", "\\.\\/\\", ".\\../", "..\\/." }
Below we show a nicer formatting of the return value: ./\.. /./.. \.\/\ .\../ ..\/.
26
Returns: {"/\\/\\/\\", "\\..../", "/....\\", "\\..../", "/....\\", "\\/\\/\\/" }
Below we show a nicer formatting of the return value: /\/\/\ \..../ /....\ \..../ /....\ \/\/\/
Submissions are judged against all 78 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class EncloseArea with a public method vector<string> enclose(int A) · 78 test cases · 2 s / 256 MB per case