Statistics

Problem Statement for "NiceTable"

Problem Statement

You are given a String[] t that describes a rectangular table of zeroes and ones. Each character in t is either '0' or '1'.

We say that a table is nice if there are two sequences x, y of zeroes and ones such that for each valid pair of indices i, j we have t[i][j] = x[i] xor y[j].

Some technical remarks:

  • The number of elements in x should be equal to the number of rows of the table, i.e., the number of elements in t.
  • The number of elements in y should be equal to the number of columns of the table, i.e., the length of each string in t.
  • The operation xor (exclusive or) is defined as follows: 0 xor 0 = 0, 1 xor 1 = 0, 0 xor 1 = 1, and 1 xor 0 = 1.

Verify whether the given table is nice. Return "Nice" if it is nice and "Not nice" otherwise. Note that the return value is case-sensitive.

Definition

Class:
NiceTable
Method:
isNice
Parameters:
String[]
Returns:
String
Method signature:
String isNice(String[] t)
(be sure your method is public)

Constraints

  • t will contain between 1 and 5 elements, inclusive.
  • Each element of t will contain between 1 and 5 characters, inclusive.
  • All elements of t will contain the same number of characters.
  • Each element of t will consist only of characters '0' and '1'.

Examples

  1. {"01", "10"}

    Returns: "Nice"

    One valid choice is to choose x = y = {1, 0}.

  2. {"01", "11"}

    Returns: "Not nice"

    Assume that t is nice. The sequences x and y have to satisfy the following constraints: x[0] xor y[0] = 0 x[0] xor y[1] = 1 x[1] xor y[0] = 1 x[1] xor y[1] = 1 From the first constraint we see that x[0] = y[0]. From the second and the third constraint we can then derive that we must also have x[1] = y[1]. But then the fourth constraint is not satisfied, which is a contradiction. Therefore, this t is not nice.

  3. {"010", "101", "010"}

    Returns: "Nice"

    Here one of possible x and y are x = y = "101".

  4. {"01", "01"}

    Returns: "Nice"

  5. {"1"}

    Returns: "Nice"

  6. {"111", "000", "111"}

    Returns: "Nice"

  7. {"001", "000", "001"}

    Returns: "Not nice"

  8. {"01100", "01100", "01100", "01100", "01100"}

    Returns: "Nice"

  9. {"0", "1", "0", "1", "0"}

    Returns: "Nice"

  10. {"11000"}

    Returns: "Nice"

  11. {"0010", "1101", "0010"}

    Returns: "Nice"

  12. {"00111", "00111"}

    Returns: "Nice"

  13. {"110", "110", "110", "001", "110"}

    Returns: "Nice"

  14. {"00111", "00111", "00111", "00111", "00111"}

    Returns: "Nice"

  15. {"0100", "1011", "0100"}

    Returns: "Nice"

    Here, one valid choice is x = {1, 0, 1} and y = {1, 0, 1, 1}.

  16. {"01011", "01011", "10100", "01011", "10000"}

    Returns: "Not nice"

  17. {"10111", "10110", "10111", "00000", "10111"}

    Returns: "Not nice"

  18. {"11", "10", "11", "11", "11"}

    Returns: "Not nice"

  19. {"1110", "0001", "0001"}

    Returns: "Nice"

  20. {"10010", "01101", "11101", "01010", "11101"}

    Returns: "Not nice"

  21. {"1001", "1000", "1000"}

    Returns: "Not nice"

  22. {"11111", "11111", "11111", "11111", "11111"}

    Returns: "Nice"

  23. {"10101", "01010", "10101", "01010", "10101"}

    Returns: "Nice"

  24. {"11100", "11100", "11100", "00011", "00011"}

    Returns: "Nice"

  25. {"00000", "00000", "00000", "00000", "00000"}

    Returns: "Nice"

  26. {"111", "111"}

    Returns: "Nice"

  27. {"0100", "1011", "0100" }

    Returns: "Nice"

  28. {"01", "10" }

    Returns: "Nice"

  29. {"0100", "1011" }

    Returns: "Nice"

  30. {"00", "00" }

    Returns: "Nice"

  31. {"01", "11" }

    Returns: "Not nice"

  32. {"110", "011" }

    Returns: "Not nice"

  33. {"0" }

    Returns: "Nice"

  34. {"000", "000", "000" }

    Returns: "Nice"

  35. {"1" }

    Returns: "Nice"

  36. {"10101", "01010", "11111", "00011", "10111" }

    Returns: "Not nice"

  37. {"1", "1" }

    Returns: "Nice"

  38. {"01", "01" }

    Returns: "Nice"

  39. {"10", "01" }

    Returns: "Nice"

  40. {"001", "000" }

    Returns: "Not nice"

  41. {"111", "111", "111" }

    Returns: "Nice"

  42. {"11", "11" }

    Returns: "Nice"

  43. {"100", "100" }

    Returns: "Nice"


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: