#P5164. Circular Map Task Assignment
Circular Map Task Assignment
Circular Map Task Assignment
xtq wants to design a circular map, which can be viewed as a circle with arbitrarily many non-overlapping check-in points placed on its circumference. Each check-in point is assigned a subset of tasks. Consider that the set of all possible tasks is a k-element set. Hence, there are exactly $2^k$ distinct subsets (denoted by $A_1,A_2,\dots,A_{2^k}$). Each check-in point is assigned exactly one of these subsets (note that different points may have the same subset).
The following two conditions must be met:
- For any two distinct task subsets $A_i$ and $A_j$ satisfying $$|\,|A_i| - |A_j|\,| = 1,$$ there must be exactly one pair of consecutive check-in points whose tasks are $A_i$ and $A_j$ (in any order).
- For any two consecutive check-in points with task subsets $A_i$ and $A_j$, it must hold that $$|\,|A_i| - |A_j|\,| = 1.$$
Here, $|A_i|$ denotes the number of elements in the subset $A_i$, and $|a+b|$ denotes the absolute value of $a+b$.
Now, given an integer n, you are to determine all possible integers k (with $2 \leq k \leq n$) for which there exists at least one valid placement of check-in points and task assignments satisfying the conditions above.
Observation: The problem can be interpreted in terms of the hypercube graph $Q_k$, where each vertex corresponds to a subset of the given k-element set and an edge exists between two vertices if the corresponding subsets differ in exactly one element. Notice that for any vertex the degree is $k$, and an Eulerian circuit (a cycle using every edge exactly once) in a graph exists if and only if every vertex has even degree. Hence, an Eulerian circuit exists if and only if k is even. That is, there exists a valid arrangement if and only if k is even.
inputFormat
The input consists of a single integer n ($n \geq 2$).
outputFormat
Output all even integers k such that $2 \leq k \leq n$, separated by spaces.
If there is no valid k, (which will not happen under the given constraints), output an empty line.
sample
2
2