Connection Status:
Competition Arena > CubeNets
SRM 417 · 2008-09-10 · by Pawa · Math, Simulation
Class Name: CubeNets
Return Type: String
Method Name: isCubeNet
Arg Types: (vector<string>)
Problem Statement

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 String[] figure. Each element of figure will consist of '.' (dot) and '#' (sharp) characters only. A sharp represents one of the six squares, whereas a dot represents an empty space. Return "YES" if figure represents a cube net, or "NO" otherwise (all quotes for clarity).

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.
Examples
0)
{"..#.",
 "####",
 "..#."}
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.

1)
{"###",
 "###"}
Returns: "NO"

This is not a cube net.

2)
{"..#.",
"####",
".#.."}
Returns: "YES"
3)
{"##..",
 ".##.",
 "..##"}
Returns: "YES"
4)
{"####",
 "...#",
 "...#"}
Returns: "NO"

Submissions are judged against all 145 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

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

Submitting as anonymous