QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 512 MB Points totaux : 100

#4326. Maliand

Statistiques

The Maliand brothers, Adrian and Vedran, spend their free time playing computer games on the family computer. They are very passionate about it, so things often get out of control, which has a very negative impact on their mother's health. Their mother is an artist, and an artist must be healthy. Therefore, she decided to introduce a schedule that will prescribe for each brother which days of the week he is allowed to spend playing on the computer.

Since the Maliands are an artistic family, they decided that their week consists of $N$ consecutive days. The mother will allow Adrian to spend exactly $K$ days per week playing games, while she will allow Vedran to spend exactly $L$ days per week playing games. She will hand them the schedules today, and Adrian and Vedran will follow them starting tomorrow.

So as not to appear too strict with her sons, she decided to allow them to start following the schedule from an arbitrary day written on the schedule. Of course, after that, they must strictly follow the schedule in the order it is written, assuming that the schedule repeats periodically to infinity.

For example, suppose $N = 3$, $K = 2$, and Adrian received the schedule $(1, 0, 1)$, where $1$ indicates that he is allowed to play on the computer that day, and $0$ indicates that he is not. If Adrian decides to follow the schedule starting from the second written day, it means he will not play tomorrow, then he will play for the next two days, then he will not play for one day, and so on.

Mrs. Maliand is aware that Adrian and Vedran will be happiest (and loudest) on the days when both of them can play on the computer, and she concludes that they will choose the start of following the schedule so as to maximize the number of such days. On the other hand, she will be least happy then, so she wants to create such schedules that the number of days when both of them can play on the computer is as small as possible, assuming that Adrian and Vedran will choose the start of following the schedule so that this number is maximized.

Help Mrs. Maliand determine the schedules that will minimize the number of days in a week when both boys will be allowed to play on the computer.

Input

The first line contains the numbers $N$, $K$, and $L$ from the problem description ($0 \le K, L \le N$).

Output

In the first line, print the number of days in a week when both boys will be allowed to play on the computer if Mrs. Maliand determines the schedules optimally.

In the second line, print Adrian's schedule as a binary string of length $N$ containing $K$ ones. Here, the digit $1$ indicates that Adrian is allowed to play on the computer that day, while the digit $0$ indicates the opposite.

In the third line, print Vedran's schedule as a binary string of length $N$ containing $L$ ones. The interpretation of this output is analogous to the interpretation of Adrian's schedule from the previous paragraph.

If there are multiple correct solutions, print any one.

Subtasks

Subtask Points Constraints
1 5 $1 \le N \le 13$
2 50 $1 \le N \le 5\,000$
3 45 $1 \le N \le 500\,000$

Examples

Input 1

6 4 3

Output 1

2
011011
101010

Note 1

If both Adrian and Vedran decide to follow the schedule from the first written day, then both will play on the computer on the third and fifth day (starting from tomorrow). It can be shown that Mrs. Maliand cannot create better schedules.

Input 2

5 2 0

Output 2

0
01001
00000

Note 2

Since Vedran is not allowed to play on the computer at all, the solution is $0$ regardless of Adrian's schedule and his decision on the start of following the schedule.

Input 3

10 7 6

Output 3

5
1101100111
1110001101

Note 3

If Adrian decides to follow the schedule from the first written day, and Vedran from the fourth written day, then both will play on the computer on the fourth, fifth, eighth, ninth, and tenth day (starting from tomorrow). It can be shown that Mrs. Maliand cannot create better schedules.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.