National Olympiad in Informatics, China, 1999

Day 1, Problem 1 - 01 Sequence

Given 7 positive integers N, A0, B0, L0, A1, B1, L1, determine a 01 sequence S = s1 s2 … si … sN, such that:

  1. si = 0 or si = 1 for 1 ≤ iN;
  2. For any of S's length L0 consecutive subsequence sj sj+1 … sj+L0-1, the number of 0's must be between A0 and B0, inclusive.
  3. For any of S's length L1 consecutive subsequence sj sj+1 … sj+L1-1, 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 Format

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

Output Format

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

Sample Input

6 1 2 3 1 1 2

Sample Output

010101

All Submissions
Best Solutions


Point Value: 20 (partial)
Time Limit: 1.00s
Memory Limit: 16M
Added: May 04, 2014

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

It's quiet in here...