Many LCS
Time limit4sMemory limit1024 MB
Given K, construct two binary strings of length at most 8848 that have exactly K distinct longest common subsequences.
- Level
Hard8 of 10
- Topics
- Combinatorics, Dynamic programming, String
- Solved
- No attempts yet
Problem
Given , construct two non-empty binary strings and of length at most 8848 such that they have exactly different longest common subsequences. More formally, if is the length of the longest common subsequence of and , there should exist exactly distinct binary strings of length which are subsequences of both and .
It is guaranteed that under the constraints of this problem such strings always exist.
Input
The only line of input contains a single integer ().
Output
Print non-empty binary strings and on separate lines. The length of each of them should not exceed 8848. They can have different lengths.
If there is more than one solution, you can print any one of them.
Hint
In the first example, the longest common subsequence of 1111 and 00 has length 0, and there is only one string of length 0 that is a subsequence of both, the empty string.
In the second example, the longest common subsequence of 10 and 01 has length 1, and there are 2 strings of length 1 that are subsequences of both and : 0 and 1.
In the third example, the longest common subsequence of 010 and 1001 has length 2, and there are 3 strings of length 2 that are subsequences of both and : 00, 01, and 10.
It would be disrespectful to make strings longer than Everest...