Statistics

Problem Statement for "UnfoldingTriangles"

Problem Statement

NOTE: This problem statement contains images that may not display properly if viewed outside of the applet.

You are given a white rectangular grid made up of square cells. Some cells contain black squares, and some contain black squares that have been folded in half to form right triangles, such that one of their sides matches the grid line to the right of the cell and another side of the triangle matches the grid line to the bottom of the cell. At most unfoldLimit of these triangles can be unfolded to become black squares. However, black squares cannot be folded to become triangles.

We are interested in forming the largest possible proper black triangle in the grid using the aforementioned operations. A black triangle is considered proper within a grid configuration if no other black shape shares a line segment with it. However, black shapes may still share one or more points with the triangle. The size of a triangle is defined as the number of grid cells that are currently occupied by the triangle.

The grid will be given as a String[], where the j-th character of the i-th element represents the cell at row i, column j. '.' represents an empty cell, '#' represents a cell containing a black square, and '/' represents a cell containing a black triangle. Return the largest possible size for a proper triangle that can be formed in the given grid by unfolding at most unfoldLimit triangles. In case it is not possible to form a proper black triangle in the grid, return -1.

For example, consider the following input grid:




If unfoldLimit is greater than or equal to 3, the largest possible proper triangle size is 10:
   



If unfoldLimit is 2, the largest possible proper triangle size is 3:
   

Larger black triangles are possible, but they would not be proper triangles.

Definition

Class:
UnfoldingTriangles
Method:
solve
Parameters:
String[], int
Returns:
int
Method signature:
int solve(String[] grid, int unfoldLimit)
(be sure your method is public)

Constraints

  • grid will contain between 1 and 50 elements, inclusive.
  • Each element of grid will contain between 1 and 50 characters, inclusive.
  • Each element of grid will contain the same number of characters.
  • Each character in grid will be '.', '#' or '/'.
  • unfoldLimit will be between 1 and 2500, inclusive.

Examples

  1. {".../", "../#", "./#/", "/#//"}

    4

    Returns: 10

  2. {".../", "../#", "./#/", "/#//"}

    2

    Returns: 3

    Examples 1 and 0 were explained in the problem statement.

  3. {"////", "////", "////", "////"}

    5

    Returns: 6

  4. {".....#...", "....###.."}

    10

    Returns: -1

  5. {"./#....", "...../.", ".....#."}

    2

    Returns: -1

  6. {"...../", "..../#", ".../#/", "../#/#", "./#/#/", "/#/#/#"}

    6

    Returns: 21

  7. {"...../", "..../#", ".../#/", "../#/#", "./#/#/", "/#/#/#"}

    2

    Returns: 10

  8. {"...../", "..../#", ".../#/", "../#/#", "./#/#/", "/#/#/#"}

    1

    Returns: 3

  9. {"...../", "..../#", ".../#/", "../#/#", "./#/#/", "/#/#/#"}

    5

    Returns: 10

  10. {"#//#", "#//#", "####", "///#"}

    4

    Returns: 1

  11. {"/#./.#/..#/#..","/...#./#.#/.//","##/#.////.//./","//#/#.##.#.../","/#/..##.//##.#"}

    1

    Returns: 1

  12. {"#..#...#.../#","///.#/#/##.##","#####..#...#/",".###/.//..../","../##./..#/#.","###/#/..//./#",".##.#/##./#//","###//###.##/#","/..###//#.###","./#//./######","...#/..././#/","/#./..##./#/.","./##.#.#/....",".//..#...///#","#/#./#/./#../","/#/..#/###.#.","/#.#.###/##.#","#/##/#/###./.","/./#/##.///.#","./#.###/..../","///./.#.#..#/","/#.//##.###/#","#/..#.#././..","..#.##../../#","././/#./##/#/","/#.#.##/###/.",".#../#..#/../","/.#/####.#...","/.././#/.#//#",".//##.//#.#..","#/.#..#.//#/.","/#/.#./#/#./.","#.####.#/././","//.#./.....##","#/#.///.#..#/","#..//...//#/#","..#.#/.#/##//","####.#./..##.","##./#/#..#..#","/..##.##//.#.","./#.///#/##.#",".///..#/.#/.#","/#./###//./#/"}

    59

    Returns: 3

  13. {"///.//.#..//...//.#/#/.#.//.#//././.##./",".////..#.###/##/./..#..../#.//#.#///.##/",".//#.##/#/.//./#/.#//#/..#..##.//##.//#/","##./.###/##/....#//./#.##/.##//##..###/.","#/#/.#.#/#//././##.//.#../#//./#..///#/#","/.#/#/#../.####/#.#././././#.##...##/./#","/#//##//#/..#../#./././././.../.#/./##/#","./.#...//#/##//.//#/##../.##.##////#./#/","#/.#./#.//#./#/#/./..##./##//...#.//.#/#","#.#.#//#.#/##.#/#./#/##./#.##/##/.#/.../","#./#....#//..##.####.//.#./#..##/##///..","#..#.#../#//.#/#/..//#//#//./../.#..#//.","##/.###./.#...##./#../#/////.###//#.#.#.","##...#.##.##/...#/##//#/...###.//.#.//./","#./###.....#/###..#////#.#//.////##/.##.","#./#./#.#/.##//.//###.//.//.///#./#/////",".#//...././/...#../.#//./#//.#/#//##/#..",".#./#/#./.../..#.///.#/#../##/###/##./..","#../.#.###.../.#.//#.#####///##/##/./###","/#.....///../#//./#.#..##.././....#.#//#","//....//......//#../###//.../.#.//###.#/",".##///#/#./#//.//#.####./.#/..../..///##","..../#.#.#//#//..#.//#./####../.##/#/#/#","/.#./...././.###/.#./../.../////.###//.#",".##////#./#.##/..../..//.#//./.#././//.#","#.#/./#.#//##//##/..//.#./##///#./././##","./#.#.#/#//#./#..//#./...//#.////.#../.#","#/#..#/...#/#////./.#.##//././//..##/.##","#/##/../##.##././##.##.#//.#.#./../////#","##/.#//.../#./#///###/#########/#.##.#.#"}

    127

    Returns: 6

  14. {".##..#//#.#/.///./#/#./#.#.#.##/#/.//.#//.#","/.#.##/.#./../#/.....//../.#/.###.#/.//#../","/.##/..//#../#/#//.#/####/###.#.//./.#####/","/#/./###////.././//###/////#/#.//#/##///##/","#/#/#..##/./..#.#//#/#../###/....//././/###","#.//./#//#../.###./###/##..#.////.#./#./#//","####.//./#...//#/.#/..///#.#.../././#/././.",".#./...//.##/./#.#////./.#.#.#/./.#...###//","#/#/##.#//.#//.##//..#/.#.##.//#/###//##.#.","/.././#./##.///..##.#.###//#./.#.###..###/.","./#.#///#./#../#/...././##././#////.#//./##","/.##/.##.####.###//#../.#.#/#../#././////#/","/.//##..//#./...#/.##/##//#./###/.//.././/#",".##/../###//.#.///#./#.././...#/#.##/..#//.","...##.#/./#..#//.//##.#/#/.#//#.#///##///#/","###////#...././#/.//.###.///#../#/#..##/#//","/../#...#/#/#.#/.##///#..#.######/...#.####","/#.#./..//##/...//.#.///##./##.#/#/../#/../",".#/.//.#//./###.#.//#/#///.##.#/#./...../#.",".///##//##.#./.#..##..///.##///./..##...///","///////.//.#.../.#/##//////#....#..#.#/#...","#.##//././#..###/#/#//./..###//.//##/#../##","###./#././/#....#.###..##..#.//###./..##...",".#/#.//#/.##./#//././//.#../.././..#//.#/#/","#..#..#/#//..##/../#..#//.#...##../#./.#//.","../#/.##..##//../#..#/#.##..//#...#/###//#.","##/###.//#//./####...#/#/#././##.#.##/#//./","//##.//#//../....#.#.###.../#/..././/.##.//","#.#./#.#.#.././//././..#//.#/#///.#/#..///#",".####.///#./.#.#/##./#./.#/.#/.#/../.#.##//","##/#.///###//#..##.....//#.#///.///#///#./#","///./#//./.#/..#.././##..#/#./#.#/.#.#/.#//","#..###.#.#./##/.//.#././/.#/./#......#.#.#/","/###.#.##.#/.///.#.#./.#./#.###..////##/.#/","/#..#/.#./.#..#/##../..../#.#/#..#/././##./","....#./#.#////#.#//..././##/.#.#.#####././/","##/.#/###.#//#.#../..#./#./#./.#././#/...#.","#####.###/#.#/#..##/#/##..//....###/#.#.//."}

    2

    Returns: 6

  15. {"/#./#////#.////..##./.###.#/##./#...#..///#//.","###////.././.####/####.///##..##////#//##/.#//","//##..//././/#/.####../.####..#.//.#.//./.#/#.","#/.../.#/#/./#/#./.#./####/#/#../././//////#/#","#.##.###//../..#/###./#///...#.#//..//..../#/.","/.#.#/./##./#./.##./#/.#/.##/##.////./.#/../#/","./.#/##././.##../.#./..//././#/#////#../#/.###",".////..//#./#.###..#.//.//..####.#////.//.#.#/","#/.#//.#/./##///./#.#...././/#/..#.#.#/###//#.","/##..##..###/##./......##//.#/#/.././//...../#","././...///#/.//..###../////#.../.#..##/#/./#./","#/#.#.///#///#.###../////.#...//#//./#./#./#./","//#./..#/.#/...//./.#././.##...#/./.#.###././#","#..../..#/#//./.#//./#././###/.#//#./##/.##/#/","#//..#.#./###/.####////.///.#.#/////...././//#","/#/./../././#/#/#//////#//...#../#//###.#/.###","###/#././.#...#./#/#.##..##../.#../#.#///.#/##","##.//.//./..#///.#/../.#/#.//#.//##/####//.#//",".#/#/.#/#/.#/./#/..#/.//.#.#####/#/##./.#./#/#","/.#/.##/./.#..//##//.//./#/.#..//./##//.//..//","##/.../..##./#####...##./..#.##..##/.#/////#/.","#./..#./#.#//#/#.../....###.#.##.##..#/./#/./.","#/##..###.#######//..//#.#./../#./..#/.//.#.#/",".###/..///.//.#..###./.#//###//#.//#/#./#...#.","###/./.#./.#...#//#/../.###.././//#.../#./#//#","././.#///./#///.///./.#.....#.##.#///#.##..#/.","//.....#/##/#/..../####..#/.##///..#/#/...###/","###/..//#..#..##..#.#/.##//./#.#/#/..///.#/#/#"}

    165

    Returns: 3

  16. {"///.##/#/##.//.//..//","/..//#/##./#//../../#","##////#.//#../#/.///.","#/...#/###.////.//.#.","/.#././/#.//###..../#",".//#.../#.#.//##//..#","#.#..#/#//./#.#./###.","./.#/##.##/.././##.##","#..//#...///#.//.#/##","/.###.#././/#.../..#/","/###.///.#/#/#///./#.","..##/../#../##/..##.#","##/.##.##..///#/.....","###//./.#/../.#/#.//#","#..//#//#..../....#/#","##..#/.//.#/#./###///","//##.////###..#/#.#/#","//.#///#/#///.##..#.#","//../#./...##././..##","/#//././#./.#...//.#/","//#/#/#..///#...#.#//","//###///##//###/./#.#","##//.../../##.#/.///#","/##/##./#/#.#/../..//","/#/.//...//////.#//#/",".//..//#/...../../#/#","..//..../#.//.//#..#/","///##.##.#..###./#/#/",".#.././#/././/.#...//","#//...././/.#////#.#/","#.././/##.#.#/./..##/","/#/#/.##.##.#//./#.//","/#./#/#.#//#.#.###/##",".#///#././....//###//","////.#./#/..././.#/#.","##./##/#####.##/###//","/..#.#/####/#.##//#/.","...#.#/.#..#.#..#.#..","#/..#/#/#//#......./#"}

    2

    Returns: 3

  17. {"#./..#../...////#/.#//../#/#.#/##..#//",".####/#//#.#//.#/#/.#/#.#/..#..#..#../","....///#////.#/##/.#/.###/.##//..#/.#.","//#////./.##.###.//###..#/./##//##./#.","/##/##.#../#/./###///.##././.#//##.#..","#/#/.##../##.///.///./#./.#../##.#./..","///#/#.#./#//.#//#.//##/.../#...#../..","..##/./////#//#../..//..///////##/../#","#.#../..#///...#./.#//#./#.../#/#./.#.","..#../##../#./#.#///.////##.#.///##/#/","###.././///#/.//..#././//####./.###./#",".###/./.##//##/#..#/./....//./.#...#/.",".#..#.../.#///#/#/./#/.//##/../#../#/#","/.##/##/...#/./###...#/.../////#///../","#/###.#/../.#....#//.////./#.#.##/../.","..././../#/##.//#.//..#/##//./.##/##/."}

    3

    Returns: 3

  18. {"/##/#/.#/.//#/./#.##","#.##./#.##../.#./#./","/.#//#//#/.#.//#/.#/","#//.////#/./#/#.//.#","///#././/.//#/./#/#.","##.../.#/../.#.##.#/","/#/./#/./../####//#.","///#...#/./#/././../","..##/##../###.//..//","##//##/#/.#//####/#.","//./.#.###...#../##/","//.#/.#//...//#/.../","///.#/.#/####.##...#","#.././.##///##.#.///",".//.#.#/..#.##.#/.##","./#/../..#.#/////../","#./.#.#././/#/././##","//#..//.#.#//.#/#../","/./#.///##.###./.#.#"}

    8

    Returns: 6

  19. {"./#/#////..//#/.#//#..###.//..///./.#...//.","#.//.#/.//#/.#..#//#///##./#/##//.##/###/.#",".../.#...##//##./././../../#.//#.###../#/#/","#/.#.###/#...///##/.###...#/.#.#.#/.#//../#","##..////..../.##/.#////./..../#//#.#/#/#.##","##.#/.#././#..#//#///#/.###.#.././/#./.#./#","/#.###/##///...##/#...#/#/.##/.##.##...//.#","#.##/#####//##//.////.#/./..##../#..//#.##/",".##/.#/##/.////#.#/#####././.##././////#.#.","##.././.###//#/.##././/#/#././.../##///.//.","/#..#.///...##./#/.//.#../#../##/#/#/..../#",".#/./.#.#/#./###/#.#/.//./#.#.../.#..///#.#",".#./##//.#//##/##.../././###/#.../..##/./#.","../#.#/.#..#.//#/.#../###..////.#./#.#.##..",".#/./###.#/./##/#/..#.////#../#...#/###.//.",".///#//###//#/##//#.#..#.###/..//##.#./#//#","#.///##.#//#///#.#...///#./../...####.///#.","//#//.#/#//#/.#......#../../.#/####////.//.","#.##.#/#/##//./....//##//#/.##/.###../../.#","###/.#./#..//.#//#/./.#///.//##/./#./.###..","/.##.#//##/###/#././///./##/##../##///../##","//././/.#//..#../.#//././#/...###/#.#..##/.","#./.#..//#.#./#.../#//..##..//#...##/#./#..","/.#../#///////.//./##/.##.../#.////#/##.///","#####..//..###///././##.#./.##.//#..//..##/","..////.#/.//..##/#./#./.#......#.#/.#.#.#./","//#./././##.##/#.#/.#/./#/.##./#/#/.###..#/",".//#.#//.#..#./##/#/#//#./#/#.##.##.../##.#"}

    1

    Returns: 3

  20. {"/.###...#..//#//./##/./##.###.///.###.//.#",".//#/.///#/...../#.#/../##////./...//#./..","##./#.//#..#/.#/##./#/#.##.../....##./#..#",".#/#//.......#/#.../#../.#/.....//#/.#./##","..//.//#./#/.//#/..#.///./#..##.##.##./#./","/#/.#/#.#/./...##/#//.../..#/./#././.##///","./#./##.#/#/.///#.###/...#..../#./#//.#./.",".#..///.##..../../##/#...//.#.#///#//#../#","..//##//././././../.../...//....#//.#..#..","/#....##/###./##/./#./#/#.##.#....//#//#/.","/.////#..##///.#/..##//.##/.#.././/...#../","##/##/.##........##../../###/#/##.##./#/./",".##.##//../..//#/../#././//././/./####.//.",".///#./.....////./#//#//#/....##//#./.#/##","#.///.../#.#/#/..#.##/#/###.//..#..../..#.","...#.//..../#../#//.//.#####/./#..#./###..",".#.//.//.#///#.#/.//#.##/./.#.//#./#//.//#","././/#/#./..#./#/#....##..##.###..///.#/..","//..////#//###/#..//.#./..././#/#//#..../#","/.###/..#.###/#...#//...#/./...../#...../.","/.../#.###./#.###///#..##/.#/##././.#/..#.","/#..#/##.#./....###..##...///###/..//.//#.","/////#/../#/#//.///###//.##/../.##/..../..",".#/.#//#/.#////#/####//#....#/#/.#//#/#./.","#/..//###.///#..#..../##./.#...///#/..#.#/","//##./#//./.##.../###/#.#./#.#.#./#.##/#/.","/#././#...//##/##..#.#./..##.#.##../#../..","#/#./....##/..#/#./#/#.//.#/#./#/.....#///",".#././..#/##.##./...//.#/.#/././#/////../#","####./////..##//../..###/..#/#////#/.//##.","////##.#.#/#.//..//.#./.#.//..#/#/..#/.//.","#//#.##/#.##././/..//#//././#.....././//#."}

    90

    Returns: 6

  21. {"/##.#.##.#","#//.###///","..#...///.","#//#////#.","/#..#.//#/",".//##//#//","/#/##.#..#",".#/#/###/#","#..##..###","/.#./#/...","./.#/..#//","/./##.////",".#////#/##","#//..#.#/#","#.##/##/#.","././/../.#","./#./#/./.","##////.##/","./##.../..","/....#..#.","##/././#/#","///##/###/","#.#.#/#/..","#./#/.#...","/#.#./...#","#/#...//##","#/#/.#.#/#","././../.##","#/######.#","//./##/...","#.#./#.//#","/##/#.#../","/././#/.##",".#/.##....","#/...#//##","..#/.###/#","/.#//##//.","/#././..#.","../..##./#","..#/#.#/..","/#//.//#./","##.##//..#","#./#/##/..","/#.#///###","./##./##/#"}

    97

    Returns: 3

  22. {"./.###.///./#//.....//....##././..//./.#/./","##/.../.#/##/#../..#/.///.//////..####.///.",".###./##/##.//../#.##/#//#.//....#////////#","../#/.#//.../#..///#//#.#./.#/.#/./../#.#//","#/#////#.//../#../#...///.#.#..////./#.#./#","//.#..#///#....#//.//.#.//.#./##.//./###.#.","#/.//#/##//#/#/####//#./.../.#///###/##.//#","###/#//..##../###/..#//#.#.##./../#.#/././.","/#././#.....#/..//...#/.#..##./#.##/.#/#/##","..///.#./##/..###.///.../...##///...##/.#/#","/#../.#....##.##.#...#....##.//.##/...//##.","../././##/###/.#//##..//#././//.#/.#///../.","#.#..//../.../...#./.#////././//.///..#/./.","/#..#.###.###/#/#.##/#..#.#..//###/.##.#///",".##////./#.//#../.#.#///##//#//#//.#/./##//","..//#.#/#./.#.#.##.#/..#//./#/#.##/./.####.","//#.....////./.##../..#/###////....##/#/.#.","##///..///##/##...#.//.///./#//..#/#/#.#../","###//#/#.#./##..#/#/###..//./##/..//#./#./#","..###/#//##//.##/#...#.##//#/#./....//.//#.","/#//./#//.#/##..#.#//.../..###.//#..//.//##","#./#.#//./...#/./##..#####..#..#/.//#/.#/./","/##/.#/../##/#/###.///...#..../.#...#.#..#/","..###/##/././##/#../#//#./..//#.#//./../#/#","...###/#..#./#...#/...#//.//#/###/.##/#####","####.#././/#/.###/#/####.#..#/##/#///#/##/#","//#.#/#.........##././#.###...##..#/../.../","#./#/.##.#/./#/...#.//#.#...//.##/./#/////."}

    1

    Returns: 6

  23. {"/#..#.#///...#/....#.#///..././/...#/##./..#//##",".//.#..///#././/#.##/###.#.//////.#...//.#//#/##",".//.#.//##.##..#/.//#./#..#//./.#.##.#.##.#///#.","//###/./#//###.//......#//..../#././...//./..///",".###.././#.#/.##///#/.....#//.##.././.#...##/##.","#//......#//./#/.#/./#./##/.#.#/.##../.#//.#.//.","..////#/..#/.#.///.#.#/....#/#/.##/..#.////..#./","//#####./././###.##/#./#/..#/##/.//../..#..#/#./","##./#/.#.##/../.#/.//#.#/.#/.//.###.//./../.....",".#/#/##.##./.#/././#/###/##/./##/./##././/./.###","#/./.##/..../#/.#/#./#./###./././#..##./#..#/#.#","#/#/.///##.#/.#/#/.././/.#/#/.##..#/.#/.#/#.../.","##//#...##/#/#/./.../##.#.//#/.../#/#/.#/./..#/#","#./.#//./#.#//.###///#./#..####/././#/#.#/..#./#","..../..##.#/../##///..//./##.#/###//.###/#.#//#/","//.../#/..//./#.//.#.#/..#..///.##/#.///#../.#/#","##.#../##/////./#../#///#///#/#....#./###.//../#","#.#....#/...##/#.#/#./#../##.##/#.##./#.///.##.#","#/../..//#//#..#.////.#...#..././.#./#./..#././.","/##/..##///#/#/./.#.##.#.#//.//./#.#/.//..#.//.#","###/#..#...///##..///#//#.././/..#/..///.#/...//","/#///../##..#////##/./..##/...###//.#/#/.///##//","#/.#/////..##/####.#.../#.#/..##///#/..#/....##.",".#..#//#/..#.#.//##/...###/./#/.##.#/////.#../##","..###/#####..##/../#//###//#.##/##/#.//.##.#/#/.","/#./#/...//##///#.#//####/#...##//./.##...##../#","//#.#.#//./....##.##//..#/...//##...//#.#.#/.##/",".#..##.#/#/##/#/#.#////.##.#/./#..///#/##.#.//##","../..##//..#//##/#././..#././/.#////#.//.##/#...","..///..#/#..##.///#//./##.#..####/##//#/###.#/#/",".#/#.#///#./.#//.///#..####/.########//.//./#//#",".//#..#.##...#.#.###/#//.##/#.../####././.#/##/#"}

    175

    Returns: 6

  24. {"##/#/.//","../#/./.",".//.////",".#//#/..","/###.##.","/./..##.",".##.....","/#/./.#.","./##/.#.","#/.///..",".#./#//#","///####.","..#.#./.","/#..###.",".////#/#","./#.#//."}

    2

    Returns: 3

  25. {"/##../.####/////#//#/.","###.###//#.#/.###///..","#./..#.#/...###.#.##/#","./.#/../#...//#./#./##","#///#/#....##////#/../",".##.###.##//###.///./#","/.//#.#/./#//..##.../#","/.......//##//#././#..","#...#//##././/.#.#././","../..//...#/#//#/#/..#","#/#/.#.##//##//./////#","/##./#//#.#///./####./","//#/##.....#.#..##.#.#","./.#./#/##/.###.##//#."}

    34

    Returns: 3

  26. {"//#.#//#..#/#..#.#/..//./#./##########//#","##.#/#/#.#..##./#/./.#/..//.####//#.###./","./##//##.//.#.###/#.//./#./.../..#.##//##","#../..#/#/#/../.#.///##./##..#///#.#/.#./",".###./../../###//#/#.//#.##..//##.//.#/##"}

    1

    Returns: 3

  27. {"/#//#//#/###../##.../.##//.","#.//#./#./#././#.#.../#..#/","#..//##..../#//./...##//../",".#....//../../###.#.#.#../#","#///##/#/...#./#/.##//.###/",".#.#/#/#...././/#.////#./.#"}

    11

    Returns: 3

  28. {"#././.##////#.///...#####",".#/.#//..##/./.#/./##.##.",".#/././#..#/.///./#./###/","..//..#/.#/#/#/####/.#/#.","./#//#..#.####.#####.//./","./#..#.///#/./..#/////../","/.#.#.#.#./#/#./#///##...","/..###/##./#.#/#/./../.##",".##/../##/.#///...##/./.#","/##..##/##//.//#.#//...#/","..#/####./#//#/.//#/...#.","//#.//#.//#/#/.....#/##/.","#..#././##..../##.../.#./","..#..#.#//#/./##../.#/###","/#####.//#.####//.##.//#/","#.#/..#/./.##/##.//#/#/..",".##.##/...##../..#//.#../","#.#.//.//#//.#/././#/..##","/##.##..././###.///.##.#.","##//###.#..#///#/..#####/","./#/#/#...//..#/#.##//##.","/...#//.////.#////#./#//.","#/#/#../#///./....//...//","./.##//#....#/.//./##...#","/./.././//..##././#./##.#","##./#//.###..//#.///..//#","/.#/..##./.#/##/.../.##//",".#.////.#.//#///#/##/...#"}

    1

    Returns: 6

  29. {"../#####//..####/..#//###/.##.##/##//#...../","././...#.#.../..##.#/../#/#/#....///..#//##/",".//../.#/./##//.#/./..//#..///.##......./#./","../.#/./../#.//...#..##.//.#/#..//##/###/../","../##../#//.##....#####./////#.##./#.#.#/.//",".#///./.../#//##...#.///...###/././//##///##","/#..//././.#../../#.#.###.//#//.#/.#../#.###",".././//./##/##.##.##..##//.../#.../..../#/.#","###./#//#../...##/.#./#.#.///#..///####/../#","//###..#.//#..#//#./..//#///#.//###.#/#.///#","/.#//#.#/#.#/.#/././//#/##////..#/./#/../..#",".##./.#.//##//./#../.#./..##.#/##../#/#./#/#","#.../#.#..##...#.#.#//.#//#.##/#//./../#./#/","/..#/##..#.#./....#//###/...#//.//##/###..#.","/./..#.#../././/#/##...//###//####.#/#///../","#.###//.#.##//##./##/#/.//#.###.#/.##././/#/","../.###///#.##/./##.##///.#.//####.#./#./#//","/../#/##././///#/#..#.#../##//.#/#//#.#..../","/##.#../.#//../##/#.//#//###.######.//.##/#.",".#./..#.#./.#/..#/.#/././/.#/.#.#.//./.#/##.",".#/#.///.##//./.#/#.#/.#.##./#/////..#.//#.#","#//..#....#/.#/##.#././#/../#./#/#...##/##/#","....//#/#///#./.#//././///##.##./../####./##",".##//###.##/#..##//#//.#/././#./#//.#././##/",".////.//##.///#/#.##././#/.//..###.././###/.","/#.///#./.#..###..#.#...#/.#/###.../####.//.","/#..#/.#...#/..#####////#///###..#.##/#..//.",".#/..###...///#...#.#/#/#///####///#...##/##",".####/.#.///#/##.//.../#.##./..#./#/##//.#.#","##/./#/.#.###./.####.##..#//#.#/.##.#./////#"}

    190

    Returns: 3

  30. {"..#/.....#.//#.#.#./##//#.#/./","#/#///.#/.#../###//.#/.##.####","..##..##.#.../#./.././#.//.##/","/###/.//.#..#///.//##/////##/#","/#/./..#./#/##.../././//..//##","#./..///.##//#/#.##/../##./#.#","#..#//./././.#.//.#./..#/##.##","/.#./#../#/#.##//.//#...../#.#",".//##/...//./////#/.////#..##.","#/.//.#/..#..#/.#/././.#/./../",".#.//..//###//./.#.//#/...#.#.",".##///.#/#/#.#.#/##/#/.//###.#","/.#/#//###.#////###./#.####/#/","/./#..#/.////.##.#/#.##//.##./","./#/..#/#.##/#../##/#/./.#.///"}

    34

    Returns: 3

  31. {"//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////"}

    1000

    Returns: 1035

  32. {"//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////"}

    2500

    Returns: 1275

  33. {"......../........./........./........./........./.", "......./#......../#......../#......../#......../#.", "....../##......./##......./##......./##......./##.", "...../###....../##......./#.#....../###....../###.", "..../####...../####...../####...../.###...../####.", ".../#####..../#####..../#####..../#####..../######", "../######.../######.../######.../######.../######.", "./#######../#######../#######../#######../#######.", "/##.#####./########./########./########./########.", "..................................................", "......../#......../........./........./........./.", "......./#......../#......../#......../#......../#.", "....../##......./##......./##......./##......./##.", "...../###....../###....../###....../###....../###.", "..../####...../####...../####...../####...../####.", ".../#####..../#####..../#####..../#####..../#####.", "../######.../######.../######.../######.../######.", "./#######../#######../#######../#######../#######.", "/########./########./########./########./#########", "..............#.....#.................#...........", "........#........./........./.....................", "......./#......../#......../#.....................", "....../##......./##......./##................../..", "...../###....../###....../###.........../...../#..", "..../####.....#####...../####...../..../#..../##..", ".../#####..../#####..../#####..../#.../##.../###..", "../######.../######.../######.../##../###../####..", "./#######../#######../#######../###./####./#####..", "/########./########.#########.....................", "..................................................", "......../............................/............", "......./#.........................../.............", "....../##.........................................", "...../###.........................................", "..../####.........................................", ".../##.##.........................................", "../######.........................................", "./#######........./................/..............", "/########......../................................", "...............././...............#...............", "..............././...............##...............", "............../././.............###...............", "............./././.............####...............", "...........././././...........#####...............", "..........././././...........######...............", "............................#######...............", "...........................########...............", "..................................................", "..................................................", ".................................................."}

    1

    Returns: 21

  34. {"......../..", "......./#/.", "....../##..", "...../###..", "..../####..", ".../#####.#", "../######..", "./#######..", "/########..", "..../..../.", "..#........"}

    3

    Returns: 45

  35. {"//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////"}

    1225

    Returns: 1275

  36. {"//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////","//////////////////////////////////////////////////"}

    1225

    Returns: 1275

  37. {".../.../", "../#..//", "./.#.///", "/###...."}

    3

    Returns: 6

  38. {".../", "../#", "./#/", "/#//" }

    5

    Returns: 10

  39. {"." }

    12

    Returns: -1

  40. {"./#" }

    1

    Returns: -1

  41. {"..../", "...//" }

    2

    Returns: 3

  42. {"////.", "////.", "////#", "////.", "..#.." }

    10

    Returns: 6

  43. {"/", "#" }

    10

    Returns: -1

  44. {"/#" }

    1

    Returns: -1

  45. {"....####..#..///", "###.....////.///", "##..#..#..#..../", "../////#..#..///", "....////../.././", "..#########..///", ".#..#..#..#../..", "....####..#..///", ".////////.#..///" }

    10

    Returns: 3

  46. {"../", "./#", "/##", ".#." }

    122

    Returns: -1

  47. {".....#", "..../#", ".../##", "../###", "./####", "######" }

    10

    Returns: -1

  48. {"../#", "...." }

    1

    Returns: -1

  49. {"......", "......", "......", "..../.", ".../#.", "../###" }

    10

    Returns: -1

  50. {".#", "/." }

    1

    Returns: 1

  51. {"..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "............................/.....................", ".........................../......................", "........................../.......................", ".........................//.......................", "........................///.......................", ".......................////.......................", "....................../////.......................", ".....................//////.......................", "....................///////.......................", ".................../..............................", "................../...............................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", ".................................................." }

    2500

    Returns: 28

  52. {"/#", "##" }

    2500

    Returns: -1

  53. {".", ".", ".", "." }

    10

    Returns: -1

  54. {".....", ".../.", "../#.", "./##.", "...#.", "....." }

    5

    Returns: -1

  55. {".../.", "../#.", "./...", "/...#" }

    1

    Returns: 3

  56. {"../.", ".//#" }

    1

    Returns: 1

  57. {"..../", ".../.", "../#/", "./##.", "/././" }

    1

    Returns: 6


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: