6788.De Bruijn Sequence

Time Limit: 1s Memory Limit: 512MB

Your task is to construct a minimum-length bit string that contains all possible substrings of length $n$ . For example, when $n=2$ , the string 00110 is a valid solution, because its substrings of length $2$ are 00, 01, 10 and 11.

Input Format(From the terminal/stdin)

The only input line has an integer $n$ .

  • $1 \le n \le 15$

Output Format(To the terminal/stdout)

Print a minimum-length bit string that contains all substrings of length $n$ . You can print any valid solution.

Sample Input

Copy
2
 \n

Sample Output special judge

Copy
00110
     \n
Source: CSES, Graph Algorithms, 1692

Submit

请先 登录

© 2025 FAQs