NOI '99 P1 - 01 Sequence

View as PDF

Submit solution

Points: 20 (partial)
Time limit: 0.6s
Memory limit: 16M

Problem type
National Olympiad in Informatics, China, 1999

Given 7 positive integers N, A0, B0, L0, A1, B1, L1, determine a 01 sequence S=s1s2sisN, such that:

  1. si=0 or si=1 for 1iN.
  2. For any of S's length L0 consecutive subsequence sjsj+1sj+L01, the number of 0's must be between A0 and B0, inclusive.
  3. For any of S's length L1 consecutive subsequence sjsj+1sj+L11, the number of 1's must be between A1 and B1, inclusive.

For example, if N=6, A0=1, B0=2, L0=3, A1=1, B1=1, L1=2, then a sequence that satisfies the above conditions is S=010101.

Input Specification

The input will consist of one line with 7 space-separated positive integers, the values N, A0, B0, L0, A1, B1, L1 (3N1000,1A0B0L0N,1A1B1L1N).

Output Specification

The output should consist of one line. If there does not exist a 01 sequence satisfying the above conditions, then output -1. Otherwise, output any 01 sequence that satisfies the conditions.

Sample Input

Copy
6 1 2 3 1 1 2

Sample Output

Copy
010101

Problem translated to English by Alex.


Comments

There are no comments at the moment.