CubeNets
SRM 417 · 2008-09-10 · by Pawa
Problem Statement
In geometry a cube net is an arrangement of identical edge-joined squares in the plane which can be folded (along the edges) to become the faces of a cube.
In this problem you need to check if the given figure is a cube net. The given figure will be a union of six identical squares lying in the same plane and will be given to you as a
Constraints
- figure will contain between 1 and 6 elements, inclusive.
- Each element of figure will contain between 1 and 6 characters, inclusive.
- Each element of figure will contain '.' (dot) and '#' (sharp) characters only.
- All elements of figure will contain the same number of characters.
- There will be exactly 6 '#' (sharp) characters among all the elements of figure.
{"..#.",
"####",
"..#."}
Returns: "YES"
Here you can first fold across all the vertical edges to make the middle four squares become the down, right, up and left faces of the cube-to-be. One then finishes off the construction by folding across the remaining two edges to make the other two squares become the front and back faces of the cube.
{"###",
"###"}
Returns: "NO"
This is not a cube net.
{"..#.",
"####",
".#.."}
Returns: "YES"
{"##..",
".##.",
"..##"}
Returns: "YES"
{"####",
"...#",
"...#"}
Returns: "NO"
Submissions are judged against all 145 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class CubeNets with a public method string isCubeNet(vector<string> figure) · 145 test cases · 2 s / 256 MB per case