Statistics

Problem Statement for "MagicianTour"

Problem Statement

You are a magician who has two different shows. You are planning a tour of a series of cities. Given the population of each city and the roads between cities, you must plan the tour such that no two cities directly connected by a road are assigned the same show and such that the difference between the number of people who see show 1 and those who see show 2 is minimized. You have to return the difference between the number of people who will see show 1 and those who will see show 2.

The roads between the cities are specified in the String[] roads. roads[i][j] is '1' if there is a road between the ith and jth cities and is '0' if there is no road. You are guaranteed that you can pull this off. (You can schedule the shows such that no two adjacent cities are assigned the same show.) Keep in mind that each city must be assigned one of the two shows. The population of each city is specified by the int[] populations whose ith element is the population of the ith city.

Definition

Class:
MagicianTour
Method:
bestDifference
Parameters:
String[], int[]
Returns:
int
Method signature:
int bestDifference(String[] roads, int[] populations)
(be sure your method is public)

Notes

  • You, the magician, can travel between two cities regardless of whether or not they are connected by a road.

Constraints

  • populations contains between 1 and 50 elements, inclusive.
  • roads contains exactly n elements, each of which has exactly n characters, where n is the number of elements in populations.
  • Each element of populations will be between 0 and 20, inclusive.
  • Each element of roads will only contain the characters '0' and '1'.
  • You are guaranteed that you can schedule the shows such that no two adjacent cities are assigned the same show.
  • No city will have a road to itself.
  • The graph is undirected. Hence, if there is a road from city a to city b then there has to be a road from city b to city a. As a result, roads[i][j] and roads[j][i] must be the same.

Examples

  1. {"01","10"}

    {15,20}

    Returns: 5

    There are two cities of populations 15 and 20. Perform show 1 in the first and show 2 in the second or vice versa.

  2. {"0100", "1000", "0001", "0010"}

    {2,4,1,5}

    Returns: 2

  3. {"0100", "1000", "0001", "0010"}

    {2,4,2,4}

    Returns: 0

    There are four cities of populations 2, 4, 2 and 4. Perform show 1 in the first and fourth cities and perform show 2 in the second and third cities.

  4. {"0010", "0001", "1000", "0100"}

    {2,2,2,2}

    Returns: 0

  5. {"000", "000", "000"}

    {6,7,15}

    Returns: 2

    There are no roads! To keep it balanced, perform show 1 in the first and second cities and show 2 in the third city.

  6. {"0000", "0010", "0101", "0010"}

    {8,10,15,10}

    Returns: 3

  7. {"00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000"}

    {4,0,13,12,10,12,5,6,5,16,11,19,10,18,1,3,13,16,15,7,15,0,10,13,6,1,20,3,5,19,11,4,11,16,19,10,19,14,11,3,3,13,1,15,4,0,10,11,7,17}

    Returns: 1

  8. {"01000000000000000000000000000000000000000000000000", "10000000000000000000000000000000000000000000000000", "00010000000000000000000000000000000000000000000000", "00100000000000000000000000000000000000000000000000", "00000100000000000000000000000000000000000000000000", "00001000000000000000000000000000000000000000000000", "00000001000000000000000000000000000000000000000000", "00000010000000000000000000000000000000000000000000", "00000000010000000000000000000000000000000000000000", "00000000100000000000000000000000000000000000000000", "00000000000100000000000000000000000000000000000000", "00000000001000000000000000000000000000000000000000", "00000000000001000000000000000000000000000000000000", "00000000000010000000000000000000000000000000000000", "00000000000000010000000000000000000000000000000000", "00000000000000100000000000000000000000000000000000", "00000000000000000100000000000000000000000000000000", "00000000000000001000000000000000000000000000000000", "00000000000000000001000000000000000000000000000000", "00000000000000000010000000000000000000000000000000", "00000000000000000000010000000000000000000000000000", "00000000000000000000100000000000000000000000000000", "00000000000000000000000100000000000000000000000000", "00000000000000000000001000000000000000000000000000", "00000000000000000000000001000000000000000000000000", "00000000000000000000000010000000000000000000000000", "00000000000000000000000000010000000000000000000000", "00000000000000000000000000100000000000000000000000", "00000000000000000000000000000100000000000000000000", "00000000000000000000000000001000000000000000000000", "00000000000000000000000000000001000000000000000000", "00000000000000000000000000000010000000000000000000", "00000000000000000000000000000000010000000000000000", "00000000000000000000000000000000100000000000000000", "00000000000000000000000000000000000100000000000000", "00000000000000000000000000000000001000000000000000", "00000000000000000000000000000000000001000000000000", "00000000000000000000000000000000000010000000000000", "00000000000000000000000000000000000000010000000000", "00000000000000000000000000000000000000100000000000", "00000000000000000000000000000000000000000100000000", "00000000000000000000000000000000000000001000000000", "00000000000000000000000000000000000000000001000000", "00000000000000000000000000000000000000000010000000", "00000000000000000000000000000000000000000000010000", "00000000000000000000000000000000000000000000100000", "00000000000000000000000000000000000000000000000100", "00000000000000000000000000000000000000000000001000", "00000000000000000000000000000000000000000000000001", "00000000000000000000000000000000000000000000000010"}

    {15,4,20,14,13,0,4,12,7,4,5,0,0,10,10,10,1,15,18,8,15,5,20,4,14,17,4,18,19,2,18,4,9,17,18,18,16,19,9,18,3,7,17,8,16,18,14,7,12,16}

    Returns: 0

  9. {"01000000000000000000000000000000000000000000000000", "10100000000000000000000000000000000000000000000000", "01000000000000000000000000000000000000000000000000", "00001000000000000000000000000000000000000000000000", "00010100000000000000000000000000000000000000000000", "00001000000000000000000000000000000000000000000000", "00000001000000000000000000000000000000000000000000", "00000010100000000000000000000000000000000000000000", "00000001000000000000000000000000000000000000000000", "00000000001000000000000000000000000000000000000000", "00000000010100000000000000000000000000000000000000", "00000000001000000000000000000000000000000000000000", "00000000000001000000000000000000000000000000000000", "00000000000010100000000000000000000000000000000000", "00000000000001000000000000000000000000000000000000", "00000000000000001000000000000000000000000000000000", "00000000000000010100000000000000000000000000000000", "00000000000000001000000000000000000000000000000000", "00000000000000000001000000000000000000000000000000", "00000000000000000010100000000000000000000000000000", "00000000000000000001000000000000000000000000000000", "00000000000000000000001000000000000000000000000000", "00000000000000000000010100000000000000000000000000", "00000000000000000000001000000000000000000000000000", "00000000000000000000000001000000000000000000000000", "00000000000000000000000010100000000000000000000000", "00000000000000000000000001000000000000000000000000", "00000000000000000000000000001000000000000000000000", "00000000000000000000000000010100000000000000000000", "00000000000000000000000000001000000000000000000000", "00000000000000000000000000000001000000000000000000", "00000000000000000000000000000010100000000000000000", "00000000000000000000000000000001000000000000000000", "00000000000000000000000000000000001000000000000000", "00000000000000000000000000000000010100000000000000", "00000000000000000000000000000000001000000000000000", "00000000000000000000000000000000000001000000000000", "00000000000000000000000000000000000010100000000000", "00000000000000000000000000000000000001000000000000", "00000000000000000000000000000000000000001000000000", "00000000000000000000000000000000000000010100000000", "00000000000000000000000000000000000000001000000000", "00000000000000000000000000000000000000000001000000", "00000000000000000000000000000000000000000010100000", "00000000000000000000000000000000000000000001000000", "00000000000000000000000000000000000000000000001000", "00000000000000000000000000000000000000000000010100", "00000000000000000000000000000000000000000000001000", "00000000000000000000000000000000000000000000000001", "00000000000000000000000000000000000000000000000010"}

    {13,12,3,13,18,17,6,1,16,5,16,10,10,8,7,4,18,5,18,0,9,11,11,3,15,10,11,14,3,20,7,10,1,14,10,12,7,6,9,1,9,20,3,11,10,4,17,12,1,14}

    Returns: 1

  10. {"010000", "101000", "010100", "001000", "000001", "000010"}

    {1,2,1,2,0,3}

    Returns: 1

  11. {"010000", "100000", "000100", "001000", "000001", "000010"}

    {10,2,2,10,3,6}

    Returns: 3

  12. {"010000", "100000", "000100", "001000", "000001", "000010"}

    {10,8,10,8,10,3}

    Returns: 3

  13. {"010000", "100000", "000100", "001000", "000001", "000010"}

    {3,4,3,4,0,6}

    Returns: 4

  14. {"01000000000000000000000000000000000000000000000000", "10000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00001000000000000000000000000000000000000000000000", "00010000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000001000000000000000000000000000000000000000000", "00000010000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000001000000000000000000000000000000000000000", "00000000010000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000001000000000000000000000000000000000000", "00000000000010000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000001000000000000000000000000000000000", "00000000000000010000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000001000000000000000000000000000000", "00000000000000000010000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000001000000000000000000000000000", "00000000000000000000010000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000001000000000000000000000000", "00000000000000000000000010000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000001000000000000000000000", "00000000000000000000000000010000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000001000000000000000000", "00000000000000000000000000000010000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000001000000000000000", "00000000000000000000000000000000010000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000001000000000000", "00000000000000000000000000000000000010000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000001000000000", "00000000000000000000000000000000000000010000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000001000000", "00000000000000000000000000000000000000000010000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000001000", "00000000000000000000000000000000000000000000010000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000001", "00000000000000000000000000000000000000000000000010"}

    {2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,20,1}

    Returns: 1

  15. {"010000", "101000", "010000", "000010", "000101", "000010"}

    {5,5,5,2,6,2}

    Returns: 3

  16. {"010000", "101000", "010000", "000010", "000101", "000010"}

    {2,6,2,5,5,5}

    Returns: 3

  17. {"01000000000000000000000000000000000000000000000000", "10000000000000000000000000000000000000000000000000", "00010000000000000000000000000000000000000000000000", "00100000000000000000000000000000000000000000000000", "00000100000000000000000000000000000000000000000000", "00001000000000000000000000000000000000000000000000", "00000001000000000000000000000000000000000000000000", "00000010000000000000000000000000000000000000000000", "00000000010000000000000000000000000000000000000000", "00000000100000000000000000000000000000000000000000", "00000000000100000000000000000000000000000000000000", "00000000001000000000000000000000000000000000000000", "00000000000001000000000000000000000000000000000000", "00000000000010000000000000000000000000000000000000", "00000000000000010000000000000000000000000000000000", "00000000000000100000000000000000000000000000000000", "00000000000000000100000000000000000000000000000000", "00000000000000001000000000000000000000000000000000", "00000000000000000001000000000000000000000000000000", "00000000000000000010000000000000000000000000000000", "00000000000000000000010000000000000000000000000000", "00000000000000000000100000000000000000000000000000", "00000000000000000000000100000000000000000000000000", "00000000000000000000001000000000000000000000000000", "00000000000000000000000001000000000000000000000000", "00000000000000000000000010000000000000000000000000", "00000000000000000000000000010000000000000000000000", "00000000000000000000000000100000000000000000000000", "00000000000000000000000000000100000000000000000000", "00000000000000000000000000001000000000000000000000", "00000000000000000000000000000001000000000000000000", "00000000000000000000000000000010000000000000000000", "00000000000000000000000000000000010000000000000000", "00000000000000000000000000000000100000000000000000", "00000000000000000000000000000000000100000000000000", "00000000000000000000000000000000001000000000000000", "00000000000000000000000000000000000001000000000000", "00000000000000000000000000000000000010000000000000", "00000000000000000000000000000000000000010000000000", "00000000000000000000000000000000000000100000000000", "00000000000000000000000000000000000000000100000000", "00000000000000000000000000000000000000001000000000", "00000000000000000000000000000000000000000001000000", "00000000000000000000000000000000000000000010000000", "00000000000000000000000000000000000000000000010000", "00000000000000000000000000000000000000000000100000", "00000000000000000000000000000000000000000000000100", "00000000000000000000000000000000000000000000001000", "00000000000000000000000000000000000000000000000001", "00000000000000000000000000000000000000000000000010"}

    {2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,20,1}

    Returns: 1

  18. {"01000000000000000000000000000000000000000000000000", "10100000000000000000000000000000000000000000000000", "01010000000000000000000000000000000000000000000000", "00101000000000000000000000000000000000000000000000", "00010100000000000000000000000000000000000000000000", "00001010000000000000000000000000000000000000000000", "00000101000000000000000000000000000000000000000000", "00000010100000000000000000000000000000000000000000", "00000001010000000000000000000000000000000000000000", "00000000101000000000000000000000000000000000000000", "00000000010100000000000000000000000000000000000000", "00000000001010000000000000000000000000000000000000", "00000000000101000000000000000000000000000000000000", "00000000000010100000000000000000000000000000000000", "00000000000001010000000000000000000000000000000000", "00000000000000101000000000000000000000000000000000", "00000000000000010100000000000000000000000000000000", "00000000000000001010000000000000000000000000000000", "00000000000000000101000000000000000000000000000000", "00000000000000000010100000000000000000000000000000", "00000000000000000001010000000000000000000000000000", "00000000000000000000101000000000000000000000000000", "00000000000000000000010100000000000000000000000000", "00000000000000000000001010000000000000000000000000", "00000000000000000000000101000000000000000000000000", "00000000000000000000000010100000000000000000000000", "00000000000000000000000001010000000000000000000000", "00000000000000000000000000101000000000000000000000", "00000000000000000000000000010100000000000000000000", "00000000000000000000000000001010000000000000000000", "00000000000000000000000000000101000000000000000000", "00000000000000000000000000000010100000000000000000", "00000000000000000000000000000001010000000000000000", "00000000000000000000000000000000101000000000000000", "00000000000000000000000000000000010100000000000000", "00000000000000000000000000000000001010000000000000", "00000000000000000000000000000000000101000000000000", "00000000000000000000000000000000000010100000000000", "00000000000000000000000000000000000001010000000000", "00000000000000000000000000000000000000101000000000", "00000000000000000000000000000000000000010100000000", "00000000000000000000000000000000000000001010000000", "00000000000000000000000000000000000000000101000000", "00000000000000000000000000000000000000000010100000", "00000000000000000000000000000000000000000001010000", "00000000000000000000000000000000000000000000101000", "00000000000000000000000000000000000000000000010100", "00000000000000000000000000000000000000000000001010", "00000000000000000000000000000000000000000000000101", "00000000000000000000000000000000000000000000000010"}

    {20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0,20,0}

    Returns: 500

  19. {"010", "101", "010"}

    {5,1,5}

    Returns: 9

  20. { "01000000000000000000000000000000000", "10100000000000000000000000000000000", "01010000000000000000000000000000000", "00101000000000000000000000000000000", "00010100000000000000000000000000000", "00001010000000000000000000000000000", "00000101000000000000000000000000000", "00000010100000000000000000000000000", "00000001010000000000000000000000000", "00000000101000000000000000000000000", "00000000010100000000000000000000000", "00000000001010000000000000000000000", "00000000000101000000000000000000000", "00000000000010100000000000000000000", "00000000000001010000000000000000000", "00000000000000101000000000000000000", "00000000000000010100000000000000000", "00000000000000001010000000000000000", "00000000000000000100000000000000000", "00000000000000000000000000000000000", "00000000000000000000010000000000000", "00000000000000000000101000000000000", "00000000000000000000010100000000000", "00000000000000000000001010000000000", "00000000000000000000000101000000000", "00000000000000000000000010100000000", "00000000000000000000000001010000000", "00000000000000000000000000101000000", "00000000000000000000000000010100000", "00000000000000000000000000001010000", "00000000000000000000000000000101000", "00000000000000000000000000000010100", "00000000000000000000000000000001010", "00000000000000000000000000000000101", "00000000000000000000000000000000010" }

    {8,15,12,9,12,6,4,6,16,1,15,3,18,15,14,8,6,6,12,13,14,15,17,15,3,8,7,8,3,19,12,9,14,19,9}

    Returns: 21

  21. {"00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000"}

    {1,1,1,4,1,1,1,1,1,1,1,1,1,1,1,1,1,20,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,20,1}

    Returns: 1

  22. { "01000000000000000000000000000000000", "10100000000000000000000000000000000", "01010000000000000000000000000000000", "00101000000000000000000000000000000", "00010100000000000000000000000000000", "00001010000000000000000000000000000", "00000101000000000000000000000000000", "00000010100000000000000000000000000", "00000001010000000000000000000000000", "00000000101000000000000000000000000", "00000000010100000000000000000000000", "00000000001010000000000000000000000", "00000000000101000000000000000000000", "00000000000010100000000000000000000", "00000000000001010000000000000000000", "00000000000000101000000000000000000", "00000000000000010100000000000000000", "00000000000000001010000000000000000", "00000000000000000100000000000000000", "00000000000000000000000000000000000", "00000000000000000000010000000000000", "00000000000000000000101000000000000", "00000000000000000000010100000000000", "00000000000000000000001010000000000", "00000000000000000000000101000000000", "00000000000000000000000010100000000", "00000000000000000000000001010000000", "00000000000000000000000000101000000", "00000000000000000000000000010100000", "00000000000000000000000000001010000", "00000000000000000000000000000101000", "00000000000000000000000000000010100", "00000000000000000000000000000001010", "00000000000000000000000000000000101", "00000000000000000000000000000000010" }

    { 8, 15, 12, 9, 12, 6, 4, 6, 16, 1, 15, 3, 18, 15, 14, 8, 6, 6, 12, 13, 14, 15, 17, 15, 3, 8, 7, 8, 3, 19, 12, 9, 14, 19, 9 }

    Returns: 21

  23. { "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000" }

    { 13, 14, 13, 14, 15, 13, 14, 13, 14, 15, 13, 14, 13, 14, 15, 13, 14, 13, 14, 15, 13, 14, 13, 14, 15, 13, 14, 13, 14, 15, 13, 14, 13, 14, 15, 13, 14, 13, 14, 15, 13, 14, 13, 14, 15, 13, 14, 13, 14, 15 }

    Returns: 0

  24. { "00000000000000000000000000000000000000000000000001", "00000000000000000000000000000000000000000000000010", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "01000000000000000000000000000000000000000000000000", "10000000000000000000000000000000000000000000000000" }

    { 1, 17, 19, 13, 20, 11, 17, 6, 2, 5, 6, 3, 5, 7, 8, 9, 20, 0, 19, 8, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 16, 17, 18, 19, 20, 15, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0 }

    Returns: 0

  25. { "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000" }

    { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }

    Returns: 1

  26. { "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000", "000000000000000000000000000000" }

    { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }

    Returns: 1

  27. { "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000" }

    { 13, 12, 3, 20, 17, 13, 12, 3, 20, 17, 13, 12, 3, 20, 17, 13, 12, 3, 20, 17, 13, 12, 3, 20, 17, 13, 12, 3, 20, 17, 13, 12, 3, 20, 17, 13, 12, 3, 20, 17, 13, 12, 3, 20, 17, 13, 12, 3, 20, 17 }

    Returns: 0

  28. { "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000" }

    { 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 15, 15, 15, 15, 15, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19 }

    Returns: 0

  29. { "0000", "0000", "0000", "0000" }

    { 20, 20, 20, 13 }

    Returns: 7

  30. { "00000", "00000", "00000", "00000", "00000" }

    { 7, 6, 5, 5, 3 }

    Returns: 0


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: