MultiplicationTable3
SRM 689 · 2016-04-01 · by cgy4ever
Problem Statement
The operation will be denoted $ and it will be defined on the finite set S = {0, 1, 2, ..., n-1}. I.e., for each ordered pair (i, j) of elements of S the operation (i $ j) will return some element of S.
For example, we can have S = {0, 1}, and we can define that (0 $ 0) = 0, (0 $ 1) = 1, (1 $ 0) = 0, and (1 $ 1) = 0.
Note that Ciel's operation is not necessarily symmetric. In other words, it is possible that for some i and j the operations (i $ j) and (j $ i) return two different values.
A subset T of S is called good if it has the following property: for any two elements i and j in T, (i $ j) is also in T.
You are given an
- The number n (i.e., the size of the set S) must be between 1 and 20, inclusive.
- The number of good subsets of the set S must be exactly x.
If there are multiple solutions, you may return any of them. You may assume that there is always at least one valid solution.
Constraints
- x will be between 1 and 1,000, inclusive.
2
Returns: {1, 1, 1, 1 }
We have chosen n = 2. Regardless of the inputs, our binary operation $ always returns 1. For this operation we have exactly x = 2 good subsets of S: the subset {1} and the subset {0,1}.
3
Returns: {0, 1, 0, 1 }
The length of the return value is 4, hence it describes an operation with n = 2. This particular return value describes the following operation: 0 $ 0 = 0 0 $ 1 = 1 1 $ 0 = 0 1 $ 1 = 1 This operation has exactly 3 good subsets: {0}, {1}, and {0,1}.
6
Returns: {0, 1, 1, 0, 1, 2, 0, 1, 2 }
31
Returns: {0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4 }
All non-empty subsets of S are good.
1
Returns: {0 }
Submissions are judged against all 43 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class MultiplicationTable3 with a public method vector<int> construct(int x) · 43 test cases · 2 s / 256 MB per case