#P10950. De Bruijn Drum Sensor Configuration
De Bruijn Drum Sensor Configuration
De Bruijn Drum Sensor Configuration
Vani is repairing a damaged drum in which the key component is a set of sensors arranged in a circle. Each sensor has two states: on (1) and off (0). If you start from every sensor and read consecutive sensors in the clockwise direction (wrapping around the circle), you obtain binary strings of length . Vani knows that these strings must all be distinct, and furthermore the drum design is so precise that takes on the maximum possible value. Given , your task is to compute and output the lexicographically smallest sensor configuration that satisfies these properties.
Note: A valid configuration is a circular binary sequence such that every possible binary string of length (there are of them) appears exactly once as a contiguous subsequence. This sequence is known as a de Bruijn sequence for -tuples over the alphabet {0, 1}.
inputFormat
The input consists of a single integer () representing the length of the binary strings.
outputFormat
Output two lines. The first line contains the integer , which is . The second line contains the lexicographically smallest de Bruijn sequence (a binary string of length ) representing the sensor configuration.
sample
1
2
01
</p>