Statistics

Problem Statement for "DoubleWeights"

Problem Statement

We have a simple undirected graph G with n nodes, labeled 0 through n-1. Each edge of this graph has two weights. You are given the description of G encoded into String[]s weight1 and weight2. If nodes i and j are connected by an edge, both weight1[i][j] and weight2[i][j] are nonzero digits ('1'-'9'), and these represent the two weights of this edge. Otherwise, both weight1[i][j] and weight2[i][j] are periods ('.').

Your task is to find the cheapest path from node 0 to node 1. The cost of a path is calculated as (W1 * W2), where W1 is the sum of all first weights and W2 is the sum of all second weights of the edges on your path. Return the smallest possible cost of a path from node 0 to node 1. If there is no such path, return -1 instead.

Definition

Class:
DoubleWeights
Method:
minimalCost
Parameters:
String[], String[]
Returns:
int
Method signature:
int minimalCost(String[] weight1, String[] weight2)
(be sure your method is public)

Constraints

  • n will be between 2 and 20, inclusive.
  • weight1 and weight2 will contain exactly n elements, each.
  • Each element in weight1 and weight2 will contain exactly n characters.
  • Each character in weight1 and weight2 will be '.' or '1' - '9'.
  • For each i, weight1[i][i] = weight2[i][i] = '.'.
  • For each i and j, weight1[i][j] = weight1[j][i].
  • For each i and j, weight2[i][j] = weight2[j][i].
  • weight1[i][j] = '.' if and only if weight2[i][j] = '.'.

Examples

  1. {"..14", "..94", "19..", "44.."}

    {"..94", "..14", "91..", "44.."}

    Returns: 64

    The best path is 0 -> 3 -> 1. The cost of this path is (4+4) * (4+4) = 64. Note that the other possible path (0 -> 2 -> 1) is more expensive. Its cost is (1+9) * (9+1) = 100.

  2. {"..14", "..14", "11..", "44.."}

    {"..94", "..94", "99..", "44.."}

    Returns: 36

    This time the best path is 0->2->1, the cost is (1+1) * (9+9) = 36.

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

    {"..", ".."}

    Returns: -1

    There is no path between node 0 and node 1, so you should return -1.

  4. {".....9", "..9...", ".9.9..", "..9.9.", "...9.9", "9...9."}

    {".....9", "..9...", ".9.9..", "..9.9.", "...9.9", "9...9."}

    Returns: 2025

  5. {".4...1", "4.1...", ".1.1..", "..1.1.", "...1.1", "1...1."}

    {".4...1", "4.1...", ".1.1..", "..1.1.", "...1.1", "1...1."}

    Returns: 16

  6. {".7745762298589865231","7.917985933724446171","79.98468554783198485","419.6754527284586726","5786.445183531375867","79474.43998929523755","686544.3368796584333","2584533.413717594127","29551934.96746422171","935289619.2161239368","8347388362.848752978","57725977718.23589176","828832914642.9359347","9434196761839.871915","84153555427538.76389","649872892358577.1784","5686534429299161.672","21478731139139376.67","378265327677418876.5","1156753718867594275."}

    {".7745762298589865231","7.917985933724446171","79.98468554783198485","419.6754527284586726","5786.445183531375867","79474.43998929523755","686544.3368796584333","2584533.413717594127","29551934.96746422171","935289619.2161239368","8347388362.848752978","57725977718.23589176","828832914642.9359347","9434196761839.871915","84153555427538.76389","649872892358577.1784","5686534429299161.672","21478731139139376.67","378265327677418876.5","1156753718867594275."}

    Returns: 4

  7. {"...................2","..5.................",".5.7................","..7.9...............","...9.6..............","....6.7.............",".....7.2............","......2.6...........",".......6.7..........","........7.9.........",".........9.2........","..........2.8.......","...........8.8......","............8.4.....",".............4.7....","..............7.6...","...............6.8..","................8.1.",".................1.2","2.................2."}

    {"...................2","..5.................",".5.7................","..7.9...............","...9.6..............","....6.7.............",".....7.2............","......2.6...........",".......6.7..........","........7.9.........",".........9.2........","..........2.8.......","...........8.8......","............8.4.....",".............4.7....","..............7.6...","...............6.8..","................8.1.",".................1.2","2.................2."}

    Returns: 11236

  8. {"...................9","..9.................",".9.9................","..9.9...............","...9.9..............","....9.9.............",".....9.9............","......9.9...........",".......9.9..........","........9.9.........",".........9.9........","..........9.9.......","...........9.9......","............9.9.....",".............9.9....","..............9.9...","...............9.9..","................9.9.",".................9.9","9.................9."}

    {"...................9","..9.................",".9.9................","..9.9...............","...9.9..............","....9.9.............",".....9.9............","......9.9...........",".......9.9..........","........9.9.........",".........9.9........","..........9.9.......","...........9.9......","............9.9.....",".............9.9....","..............9.9...","...............9.9..","................9.9.",".................9.9","9.................9."}

    Returns: 29241

  9. {"...1.............6.8","..3................3",".3.6............5...","1.6.6.............9.","...6.4...2..........","....4.1.............",".....1.6...........1","......6.2...........",".......2.1..........","....2...1.7.....2...",".........7.2........","..........2.4.......","...........4.2......","............2.2.....",".............2.9....","..............9.9...","..5......2.....9.1..","6...............1.98","...9.............9.9","83....1..........89."}

    {"...1.............6.8","..3................3",".3.6............5...","1.6.6.............9.","...6.4...2..........","....4.1.............",".....1.6...........1","......6.2...........",".......2.1..........","....2...1.7.....2...",".........7.2........","..........2.4.......","...........4.2......","............2.2.....",".............2.9....","..............9.9...","..5......2.....9.1..","6...............1.98","...9.............9.9","83....1..........89."}

    Returns: 100

  10. {"...3.....73","..7......8.",".7.4.4.....","3.4.9...9..","...9.8.....","..4.8.1....",".....1.4..5","......4.2..","...9...2.1.","78......1.8","3.....5..8."}

    {"...3.....73","..7......8.",".7.4.4.....","3.4.9...9..","...9.8.....","..4.8.1....",".....1.4..5","......4.2..","...9...2.1.","78......1.8","3.....5..8."}

    Returns: 196

  11. {".43931","4.3394","33.918","939.36","3913.1","14861."}

    {".43931","4.3394","33.918","939.36","3913.1","14861."}

    Returns: 16

  12. {".28.6299","2.121628","81.18253",".21.5986","6185.355","26293.9.","925859.3","98365.3."}

    {".28.6299","2.121628","81.18253",".21.5986","6185.355","26293.9.","925859.3","98365.3."}

    Returns: 4

  13. {"..44","..57","45.2","472."}

    {"..44","..57","45.2","472."}

    Returns: 81

  14. {".....8","..5.2.",".5.8..","..8.9.",".2.9.7","8...7."}

    {".....8","..5.2.",".5.8..","..8.9.",".2.9.7","8...7."}

    Returns: 289

  15. {"........7......4","..3.......1.....",".3.7............","..7.9..........1","...9.9..........","....9.6.......9.",".....6.5.....8..","......5.9.......","7......9.8......","........8.34....",".1.......3.5....",".........45.7...","...........7.5..","......8.....5.8.",".....9.......8.4","4..1..........4."}

    {"........7......4","..3.......1.....",".3.7............","..7.9..........1","...9.9..........","....9.6.......9.",".....6.5.....8..","......5.9.......","7......9.8......","........8.34....",".1.......3.5....",".........45.7...","...........7.5..","......8.....5.8.",".....9.......8.4","4..1..........4."}

    Returns: 225

  16. {"......31..8","..3...3865.",".3.9.1...5.","..9.471..94","...4.7....8","..177.57..2","33.1.5.8837","18...78.3..",".6....83.72",".559..3.7.6","8..4827.26."}

    {"......31..8","..3...3865.",".3.9.1...5.","..9.471..94","...4.7....8","..177.57..2","33.1.5.8837","18...78.3..",".6....83.72",".559..3.7.6","8..4827.26."}

    Returns: 36

  17. {"...........6","..4.........",".4.4.5......","..4.5.5.....","...5.6....8.","..5.6.7.....","...5.7.3....","......3.5.4.",".......5.5..","........5.5.","....8..4.5.1","6.........1."}

    {"...........6","..4.........",".4.4.5......","..4.5.5.....","...5.6....8.","..5.6.7.....","...5.7.3....","......3.5.4.",".......5.5..","........5.5.","....8..4.5.1","6.........1."}

    Returns: 729

  18. {".............3","..17........2.",".1.1..........",".71.4........9","...4.4........","....4.2.......",".....2.8......","......8.1.....",".......1.6....","........6.9...",".........9.5..","..........5.7.",".2.........7.4","3..9........4."}

    {".............3","..17........2.",".1.1..........",".71.4........9","...4.4........","....4.2.......",".....2.8......","......8.1.....",".......1.6....","........6.9...",".........9.5..","..........5.7.",".2.........7.4","3..9........4."}

    Returns: 81

  19. {"....673......1.358","..2.9....6..6.826.",".2.3...6....5..7..","..3.2..8....2.....","69.2.7.....4.....1","7...7.4..19......7","3....4.41..2.5744.","..68..4.8.3..85...","......18.7.....1..",".6...1..7.68...325",".....9.3.6.8.29433","....4.2..88.9.....",".652.......9.5411.","1.....58..2.5.79.9",".8....75..9.47.9..","327...4.134.199.2.","56....4..23.1..2.2","8...17...53..9..2."}

    {"....673......1.358","..2.9....6..6.826.",".2.3...6....5..7..","..3.2..8....2.....","69.2.7.....4.....1","7...7.4..19......7","3....4.41..2.5744.","..68..4.8.3..85...","......18.7.....1..",".6...1..7.68...325",".....9.3.6.8.29433","....4.2..88.9.....",".652.......9.5411.","1.....58..2.5.79.9",".8....75..9.47.9..","327...4.134.199.2.","56....4..23.1..2.2","8...17...53..9..2."}

    Returns: 25

  20. {"..........8","..1........",".1.29......","..2.9......","..99.7.....","....7.4....",".....4.4...","......4.6..",".......6.7.","........7.6","8........6."}

    {"..........8","..1........",".1.29......","..2.9......","..99.7.....","....7.4....",".....4.4...","......4.6..",".......6.7.","........7.6","8........6."}

    Returns: 2704

  21. {".....4","..9..8",".9.91.","..9.2.","..12.2","48..2."}

    {".....4","..9..8",".9.91.","..9.2.","..12.2","48..2."}

    Returns: 144

  22. {".............1","..9...........",".9.1....8.....","..1.1.......9.","...1.4........","....4.3.......",".....3.2......","......2.2.....","..8....2.6....","........6.5...",".........5.7..","..........7.9.","...9.......9.1","1...........1."}

    {".............1","..9...........",".9.1....8.....","..1.1.......9.","...1.4........","....4.3.......",".....3.2......","......2.2.....","..8....2.6....","........6.5...",".........5.7..","..........7.9.","...9.......9.1","1...........1."}

    Returns: 441

  23. {"...........8","..6.........",".6.8........","..8.1.......","...1.9......","....9.5.4...",".....5.2....","......2.7...",".....4.7.1..","........1.7.",".........7.3","8.........3."}

    {"...........8","..6.........",".6.8........","..8.1.......","...1.9......","....9.5.4...",".....5.2....","......2.7...",".....4.7.1..","........1.7.",".........7.3","8.........3."}

    Returns: 2209

  24. {"..3..9.823.97","..8.89.7232.9","38.5..6.257.4","..5.3..54.5..",".8.3.1....2.2","99..1.3.178..","..6..3.7.75.9","87.5..7.2.1..","2224.1.2.9...","335..77.9.2.9",".2752851.2.1.","9.........1.5","794.2.9..9.5."}

    {"..3..9.823.97","..8.89.7232.9","38.5..6.257.4","..5.3..54.5..",".8.3.1....2.2","99..1.3.178..","..6..3.7.75.9","87.5..7.2.1..","2224.1.2.9...","335..77.9.2.9",".2752851.2.1.","9.........1.5","794.2.9..9.5."}

    Returns: 16

  25. {"..............8","..1............",".1.1....3......","..1.8..........","...8.2.........","....2.6........",".....6.8.......","......8.3......","..3....3.8.....","........8.5....",".........5.1.6.","..........1.5..","...........5.1.","..........6.1.8","8............8."}

    {"..............8","..1............",".1.1....3......","..1.8..........","...8.2.........","....2.6........",".....6.8.......","......8.3......","..3....3.8.....","........8.5....",".........5.1.6.","..........1.5..","...........5.1.","..........6.1.8","8............8."}

    Returns: 1521

  26. {"......777...8","..4.........6",".4.26.......3","..2.9.9.....1","..69.8......8","....8.79.....","7..9.7.5.....","7....95.53.3.","7......5.4.71",".......34.8..",".........8.36",".......37.3.9","86318...1.69."}

    {"......777...8","..4.........6",".4.26.......3","..2.9.9.....1","..69.8......8","....8.79.....","7..9.7.5.....","7....95.53.3.","7......5.4.71",".......34.8..",".........8.36",".......37.3.9","86318...1.69."}

    Returns: 196

  27. {".95.5.918","9.6..5.59","56.4.5.85","..4.5.4..","5..5.6.2.",".55.6.526","9..4.5.6.","158.226.9","895..6.9."}

    {".95.5.918","9.6..5.59","56.4.5.85","..4.5.4..","5..5.6.2.",".55.6.526","9..4.5.6.","158.226.9","895..6.9."}

    Returns: 36

  28. {".4........3","4.2........",".2.3......9","..3.6......","...6.6.....","....6.12...",".....1.4...",".....24.87.",".......8.7.",".......77.5","3.9......5."}

    {".4........3","4.2........",".2.3......9","..3.6......","...6.6.....","....6.12...",".....1.4...",".....24.87.",".......8.7.",".......77.5","3.9......5."}

    Returns: 16

  29. {"....3.4.6","..1.....2",".1.1.....","..1.9....","3..9.4...","....4.5..","4....5.8.","......8.4","62.....4."}

    {"....3.4.6","..1.....2",".1.1.....","..1.9....","3..9.4...","....4.5..","4....5.8.","......8.4","62.....4."}

    Returns: 64

  30. {".5.2.2.8","5.19.463",".1.13.47","291.5.8.","..35.253","24..2.93",".64859.1","837.331."}

    {".5.2.2.8","5.19.463",".1.13.47","291.5.8.","..35.253","24..2.93",".64859.1","837.331."}

    Returns: 16

  31. {".22","2.5","25."}

    {".22","2.5","25."}

    Returns: 4

  32. {".1.37..721.4","1.4..1......",".4.5.7....56","3.5.9...9..8","7..9.7843...",".17.7.1.....","....81.9....","7...4.9.4..1","2..93..4.2..","1.......2.8.","..5......8.4","4.68...1..4."}

    {".1.37..721.4","1.4..1......",".4.5.7....56","3.5.9...9..8","7..9.7843...",".17.7.1.....","....81.9....","7...4.9.4..1","2..93..4.2..","1.......2.8.","..5......8.4","4.68...1..4."}

    Returns: 1

  33. {"..............6..3","..4.........5.....",".4.8.....7........","..8.3.7........7..","...3.7............","....7.9...........","...7.9.9...8......","......9.8........7",".......8.6..2.....","..7.....6.7.......",".........7.8......","......8...8.2.....",".5......2..2.4....","............4.8...","6............8.7..","...7..........7.67","...............6.1","3......7.......71."}

    {"..............6..3","..4.........5.....",".4.8.....7........","..8.3.7........7..","...3.7............","....7.9...........","...7.9.9...8......","......9.8........7",".......8.6..2.....","..7.....6.7.......",".........7.8......","......8...8.2.....",".5......2..2.4....","............4.8...","6............8.7..","...7..........7.67","...............6.1","3......7.......71."}

    Returns: 529

  34. {"..3.47..932..9","..1........4.4","31.226.96.795.","..2.1..182..5.","4.21.7..3.3..2","7.6.7.1..2.9..",".....1.8..25.4","..91..8.9.8..8","9.683..9.58...","3..2.2..5.29..","2.7.3.2882.1..",".49..95..91.83","..55.......8.6","94..2.48...36."}

    {"..3.47..932..9","..1........4.4","31.226.96.795.","..2.1..182..5.","4.21.7..3.3..2","7.6.7.1..2.9..",".....1.8..25.4","..91..8.9.8..8","9.683..9.58...","3..2.2..5.29..","2.7.3.2882.1..",".49..95..91.83","..55.......8.6","94..2.48...36."}

    Returns: 16

  35. {"...........2","..52........",".5.1..6.....",".21.7.......","...7.4......","....4.2.....","..6..2.4....","......4.4...",".......4.8.4","........8.6.",".........6.4","2.......4.4."}

    {"...........2","..52........",".5.1..6.....",".21.7.......","...7.4......","....4.2.....","..6..2.4....","......4.4...",".......4.8.4","........8.6.",".........6.4","2.......4.4."}

    Returns: 529

  36. {".....2","..592.",".5.5..",".95.3.",".2.3.7","2...7."}

    {".....2","..592.",".5.5..",".95.3.",".2.3.7","2...7."}

    Returns: 121

  37. {"...8","..83",".8.8","838."}

    {"...8","..83",".8.8","838."}

    Returns: 121

  38. {".4..9","4.9.1",".9.3.","..3.7","91.7."}

    {".4..9","4.9.1",".9.3.","..3.7","91.7."}

    Returns: 16

  39. {".79","7.2","92."}

    {".79","7.2","92."}

    Returns: 49

  40. {"..................6","..5...4..3.........",".5.2...............","..2.7..............","...7.9.............","....9.7............",".4...7.5...47......","......5.4..........",".......4.7.........",".3......7.6........",".........6.5.......","......4...5.6......","......7....6.2.18..","............2.3....",".............3.7...","............1.7.3..","............8..3.5.","................5.1","6................1."}

    {"..................6","..5...4..3.........",".5.2...............","..2.7..............","...7.9.............","....9.7............",".4...7.5...47......","......5.4..........",".......4.7.........",".3......7.6........",".........6.5.......","......4...5.6......","......7....6.2.18..","............2.3....",".............3.7...","............1.7.3..","............8..3.5.","................5.1","6................1."}

    Returns: 729

  41. {".879","8.42","74.8","928."}

    {".879","8.42","74.8","928."}

    Returns: 64

  42. {"..7...........3","..25...........","72.4...........",".54.7..........","...7.6.........","....6.4........",".....4.9.......","......9.4......",".......4.7.....","........7.4....",".........4.3...","..........3.9..","...........9.5.","............5.4","3............4."}

    {"..7...........3","..25...........","72.4...........",".54.7..........","...7.6.........","....6.4........",".....4.9.......","......9.4......",".......4.7.....","........7.4....",".........4.3...","..........3.9..","...........9.5.","............5.4","3............4."}

    Returns: 81

  43. {"................8","..4..............",".4.3.............","..3.1............","...1.2...........","....2.3..........",".....3.5....3....","......5.9........",".......9.6.......","........6.8......",".........8.34....","..........3.2....","......3...42.1..3","............1.7..",".............7.2.","..............2.8","8...........3..8."}

    {"................8","..4..............",".4.3.............","..3.1............","...1.2...........","....2.3..........",".....3.5....3....","......5.9........",".......9.6.......","........6.8......",".........8.34....","..........3.2....","......3...42.1..3","............1.7..",".............7.2.","..............2.8","8...........3..8."}

    Returns: 729

  44. {"...1....7","..6......",".6.5.....","1.5.3....","...3.2...","....2.8..",".....8.8.","......8.2","7......2."}

    {"...1....7","..6......",".6.5.....","1.5.3....","...3.2...","....2.8..",".....8.8.","......8.2","7......2."}

    Returns: 144

  45. {".................2","..7...............",".7.5..............","..5.1...........6.","...1.4............","....4.3...........",".....3.8..........","......8.3.........",".......3.5........","........5.4.......",".........4.4......","..........4.8.....","...........8.7....","............7.5...",".............5.7..","..............7.1.","...6...........1.5","2...............5."}

    {".................2","..7...............",".7.5..............","..5.1...........6.","...1.4............","....4.3...........",".....3.8..........","......8.3.........",".......3.5........","........5.4.......",".........4.4......","..........4.8.....","...........8.7....","............7.5...",".............5.7..","..............7.1.","...6...........1.5","2...............5."}

    Returns: 625

  46. {".........52..1","..5.29....7..3",".5.643...7...7","..6.3..7372..3",".243.7.2......",".93.7.5..2....",".....5.49.1...","...72.4.831...","...3..98.2..8.","5.77.2.32.8...","27.2..11.8.32.","..........3.17","........8.21.6","1373.......76."}

    {".........52..1","..5.29....7..3",".5.643...7...7","..6.3..7372..3",".243.7.2......",".93.7.5..2....",".....5.49.1...","...72.4.831...","...3..98.2..8.","5.77.2.32.8...","27.2..11.8.32.","..........3.17","........8.21.6","1373.......76."}

    Returns: 16

  47. {".39.9..6..9..8","3.64......19..","96.224.....6..",".42.3.1..94..8","9.23.2..4.7.9.","..4.2.12.7.77.","...1.1.6..8...","6....26.86..25","....4..8.3.1.8","...9.7.63.84..","91.47.8..8.373",".96..7..143.6.","....97.2..76.4","8..8...58.3.4."}

    {".39.9..6..9..8","3.64......19..","96.224.....6..",".42.3.1..94..8","9.23.2..4.7.9.","..4.2.12.7.77.","...1.1.6..8...","6....26.86..25","....4..8.3.1.8","...9.7.63.84..","91.47.8..8.373",".96..7..143.6.","....97.2..76.4","8..8...58.3.4."}

    Returns: 9

  48. {".554","5.49","54.1","491."}

    {".554","5.49","54.1","491."}

    Returns: 25

  49. {".9..7....5487..4.67","9.289.18618.....352",".2.6...7..9.478727.",".86.2.7..11..1..4..","79.2.6.....18154.1.","....6.55....2.81...",".1.7.5.1.64.7.....7",".87..51.5....4..4..",".6.....5.2.4.......","51.1..6.2.5...79.41","4891..4..5.5.57.8.7","8...1...4.5.6.9.5.3","7.4.827....6.666...","..711..4..5.6.6.2..","..8.58...77966.21..","4.7.41...9..6.2.6..",".324...4..85.216.7.","657.1....4......7.6","72....7..173.....6."}

    {".9..7....5487..4.67","9.289.18618.....352",".2.6...7..9.478727.",".86.2.7..11..1..4..","79.2.6.....18154.1.","....6.55....2.81...",".1.7.5.1.64.7.....7",".87..51.5....4..4..",".6.....5.2.4.......","51.1..6.2.5...79.41","4891..4..5.5.57.8.7","8...1...4.5.6.9.5.3","7.4.827....6.666...","..711..4..5.6.6.2..","..8.58...77966.21..","4.7.41...9..6.2.6..",".324...4..85.216.7.","657.1....4......7.6","72....7..173.....6."}

    Returns: 36

  50. {".1..93764..59.61","1.7.....9..59...",".7.9..5....6.1..","..9.4.......5...","9..4.1..715...2.","3...1.7..3.6.6..","7.5..7.8.1..7.3.","6.....8.1.7..36.","49..7..1.1.7....","....131.1.5..751","....5..7.5.3.3.6","556..6..7.3.99.9","99.5..7....9.984","..1..6.3.7399.2.","6...2.36.5..82.5","1........1694.5."}

    {".1..93764..59.61","1.7.....9..59...",".7.9..5....6.1..","..9.4.......5...","9..4.1..715...2.","3...1.7..3.6.6..","7.5..7.8.1..7.3.","6.....8.1.7..36.","49..7..1.1.7....","....131.1.5..751","....5..7.5.3.3.6","556..6..7.3.99.9","99.5..7....9.984","..1..6.3.7399.2.","6...2.36.5..82.5","1........1694.5."}

    Returns: 1

  51. {".............2","..9...........",".9.9..........","..9.5.........","...5.8........","....8.6.......",".....6.9......","......9.6.....",".......6.8....","........8.5..7",".........5.3..","..........3.1.","...........1.2","2........7..2."}

    {".............2","..9...........",".9.9..........","..9.5.........","...5.8........","....8.6.......",".....6.9......","......9.6.....",".......6.8....","........8.5..7",".........5.3..","..........3.1.","...........1.2","2........7..2."}

    Returns: 4761

  52. {".662","6.41","64.9","219."}

    {".662","6.41","64.9","219."}

    Returns: 9

  53. {"...........8..5","..2.........3..",".2.4.....5.....","..4.9..........","...9.2......3..","....2.5...6....",".....5.1.......","......1.9....1.",".......9.9.....","..5.....9.1....",".....6...1.7...","8.........7.2..",".3..3......2.4.",".......1....4.8","5............8."}

    {"...........8..5","..2.........3..",".2.4.....5.....","..4.9..........","...9.2......3..","....2.5...6....",".....5.1.......","......1.9....1.",".......9.9.....","..5.....9.1....",".....6...1.7...","8.........7.2..",".3..3......2.4.",".......1....4.8","5............8."}

    Returns: 169

  54. {".1.424.18.1","1.68.93..22",".6.745.7813","487.3776945","2.43.6.316.","49576.6.79.",".3.7.6.6613","1.763.6.356","8.891763.15",".21469151.2","1235..3652."}

    {".1.424.18.1","1.68.93..22",".6.745.7813","487.3776945","2.43.6.316.","49576.6.79.",".3.7.6.6613","1.763.6.356","8.891763.15",".21469151.2","1235..3652."}

    Returns: 1

  55. {".8712","8.997","79.45","194.7","2757."}

    {".8712","8.997","79.45","194.7","2757."}

    Returns: 64

  56. {".74.8982","7.16.366","41.7961.",".67.843.","8.98.225","93642.57","861325.7","26..577."}

    {".74.8982","7.16.366","41.7961.",".67.843.","8.98.225","93642.57","861325.7","26..577."}

    Returns: 25

  57. {".81..8....8..6","8.5..6..9....2","15.3..7..5.4..","..3.8.57.73..3","...8.6........","86..6.4.14...5","..75.4.1...2..","...7..1.64....",".9...1.6.9..2.","..57.4.49.5...","8..3.....5.2.9","..4...2...2.3.","........2..3.6","62.3.5....9.6."}

    {".81..8....8..6","8.5..6..9....2","15.3..7..5.4..","..3.8.57.73..3","...8.6........","86..6.4.14...5","..75.4.1...2..","...7..1.64....",".9...1.6.9..2.","..57.4.49.5...","8..3.....5.2.9","..4...2...2.3.","........2..3.6","62.3.5....9.6."}

    Returns: 36

  58. {".....5.126","..129.79.8",".1.9932378",".29.65498.",".996.4.4..","5.354.1.27",".724.1.281","19394.2.4.","2.78.284.1","688..71.1."}

    {".....5.126","..129.79.8",".1.9932378",".29.65498.",".996.4.4..","5.354.1.27",".724.1.281","19394.2.4.","2.78.284.1","688..71.1."}

    Returns: 25

  59. {".8...4.....7.....9.3","8.1................2",".1.6.8.......2...7..","..6.4...3.....2.....","...4.8..9.......7...","4.8.8.2.2...........",".....2.8...6...2..1.","......8.8..3..1..5..","...392.8.56......7..","........5.63......91","........66.2..3.....","7.....63.32.9.54..7.","...........9.58.....","..2.........5.78.6..","...2...1..3587.6....","......2....4.86.6...","....7..........6.7.9","9.7....57....6..7.7.","......1..9.7.....7.3","32.......1......9.3."}

    {".8...4.....7.....9.3","8.1................2",".1.6.8.......2...7..","..6.4...3.....2.....","...4.8..9.......7...","4.8.8.2.2...........",".....2.8...6...2..1.","......8.8..3..1..5..","...392.8.56......7..","........5.63......91","........66.2..3.....","7.....63.32.9.54..7.","...........9.58.....","..2.........5.78.6..","...2...1..3587.6....","......2....4.86.6...","....7..........6.7.9","9.7....57....6..7.7.","......1..9.7.....7.3","32.......1......9.3."}

    Returns: 25

  60. {"..14", "..94", "19..", "44.." }

    {"..94", "..14", "91..", "44.." }

    Returns: 64

  61. {".1111111111111111111", "1.111111111111111111", "11.11111111111111111", "111.1111111111111111", "1111.111111111111111", "11111.11111111111111", "111111.1111111111111", "1111111.111111111111", "11111111.11111111111", "111111111.1111111111", "1111111111.111111111", "11111111111.11111111", "111111111111.1111111", "1111111111111.111111", "11111111111111.11111", "111111111111111.1111", "1111111111111111.111", "11111111111111111.11", "111111111111111111.1", "1111111111111111111." }

    {".1111111111111111111", "1.111111111111111111", "11.11111111111111111", "111.1111111111111111", "1111.111111111111111", "11111.11111111111111", "111111.1111111111111", "1111111.111111111111", "11111111.11111111111", "111111111.1111111111", "1111111111.111111111", "11111111111.11111111", "111111111111.1111111", "1111111111111.111111", "11111111111111.11111", "111111111111111.1111", "1111111111111111.111", "11111111111111111.11", "111111111111111111.1", "1111111111111111111." }

    Returns: 1

  62. {".9999999999999999999", "9.999999999999999999", "99.99999999999999999", "999.9999999999999999", "9999.999999999999999", "99999.99999999999999", "999999.9999999999999", "9999999.999999999999", "99999999.99999999999", "999999999.9999999999", "9999999999.999999999", "99999999999.99999999", "999999999999.9999999", "9999999999999.999999", "99999999999999.99999", "999999999999999.9999", "9999999999999999.999", "99999999999999999.19", "999999999999999991.9", "9999999999999999999." }

    {".9999999999999999999", "9.999999999999999999", "99.99999999999999999", "999.9999999999999999", "9999.999999999999999", "99999.99999999999999", "999999.9999999999999", "9999999.999999999999", "99999999.99999999999", "999999999.9999999999", "9999999999.999999999", "99999999999.99999999", "999999999999.9999999", "9999999999999.999999", "99999999999999.99999", "999999999999999.9999", "9999999999999999.999", "99999999999999999.19", "999999999999999991.9", "9999999999999999999." }

    Returns: 81

  63. {".91", "9.1", "11." }

    {".19", "1.9", "99." }

    Returns: 9

  64. {".9999999999999999999", "9.999999999999999999", "99.99999999999999999", "999.9999999999999999", "9999.999999999999999", "99999.99999999999999", "999999.9999999999999", "9999999.999999999999", "99999999.99999999999", "999999999.9999999999", "9999999999.999999999", "99999999999.99999999", "999999999999.9999999", "9999999999999.999999", "99999999999999.99999", "999999999999999.9999", "9999999999999999.999", "99999999999999999.99", "999999999999999999.9", "9999999999999999999." }

    {".9999999999999999999", "9.999999999999999999", "99.99999999999999999", "999.9999999999999999", "9999.999999999999999", "99999.99999999999999", "999999.9999999999999", "9999999.999999999999", "99999999.99999999999", "999999999.9999999999", "9999999999.999999999", "99999999999.99999999", "999999999999.9999999", "9999999999999.999999", "99999999999999.99999", "999999999999999.9999", "9999999999999999.999", "99999999999999999.99", "999999999999999999.9", "9999999999999999999." }

    Returns: 81

  65. {"..91.", "..9.1", "99.11", "1.1..", ".11.." }

    {"..91.", "..9.1", "99.11", "1.1..", ".11.." }

    Returns: 16

  66. {".12", "1.3", "23." }

    {".91", "9.1", "11." }

    Returns: 9


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: