Connection Status:
Competition Arena > Snowflakes
SRM 291 · 2006-02-21 · by Andrew_Lazarev · Brute Force, Simulation
Class Name: Snowflakes
Return Type: String[]
Method Name: flareOut
Arg Types: (vector<string>)
Problem Statement

Problem Statement

Paper snowflakes make great decorations and they are easy to make. Take a sheet of square checkered paper with an even number of squares on each side. Fold it in half, folding the upper part up and over to the bottom part, so that you have a rectangle. Now fold that rectangle in half lengthwise, from left to right, to make a smaller square. Next, take the right upper corner of that square and fold it up and over to the left bottom corner, forming a triangle (see pictures below, cells which stay immovable after all foldings are marked red on the fifth picture). Cut out some squares along grid lines (as shown on the last picture).

? ? ? ? ?

You will be given a String[] snowflake where each element represents a single row of squares in the folded pattern (the last picture shown above). The elements in snowflake are ordered from top row to bottom row, and each row is ordered from left to right. '*' represents a cut out square, and '.' represents an intact square. Unfold the triangle by reversing the steps described above. Return this flared out snowflake as a String[] of '.' and '*' characters. You should return the contents of the entire square even if the cut out cells split the snowflake into non-connected parts.

Constraints

  • snowflake will contain between 1 and 50 elements, inclusive.
  • The ith element of snowflake (0-indexed) will contain exactly i+1 characters.
  • Each element of snowflake will contain only characters '*' or '.'.
Examples
0)
{".",
 "..",
 "*.*"}
Returns: {"*.**.*", "......", "*....*", "*....*", "......", "*.**.*" }
1)
{"*",
 "..",
 ".*.",
 ".**.",
 ".*.**"}
Returns: {"**.*..*.**", "*.**..**.*", ".*.*..*.*.", "***....***", "....**....", "....**....", "***....***", ".*.*..*.*.", "*.**..**.*", "**.*..*.**" }
2)
{".",
 "..",
 "***"}
Returns: {"******", "*....*", "*....*", "*....*", "*....*", "******" }
3)
{"*",
 ".*",
 "***"}
Returns: {"******", "**..**", "*.**.*", "*.**.*", "**..**", "******" }
4)
{".",
 "..",
 "***",
 "...."}
Returns: {"........", ".******.", ".*....*.", ".*....*.", ".*....*.", ".*....*.", ".******.", "........" }

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

Coding Area

Language: C++17 · define a public class Snowflakes with a public method vector<string> flareOut(vector<string> snowflake) · 68 test cases · 2 s / 256 MB per case

Submitting as anonymous