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, A_0, B_0, L_0, A_1, B_1, L_1, determine a 01 sequence S = s_1 s_2 \dots s_i \dots s_N, such that:

  1. s_i = 0 or s_i = 1 for 1 \le i \le N.
  2. For any of S's length L_0 consecutive subsequence s_j s_{j+1} \dots s_{j+L_0-1}, the number of 0's must be between A_0 and B_0, inclusive.
  3. For any of S's length L_1 consecutive subsequence s_j s_{j+1} \dots s_{j+L_1-1}, the number of 1's must be between A_1 and B_1, inclusive.

For example, if N = 6, A_0 = 1, B_0 = 2, L_0 = 3, A_1 = 1, B_1 = 1, L_1 = 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, A_0, B_0, L_0, A_1, B_1, L_1 (3 \le N \le 1\,000, 1 \le A_0 \le B_0 \le L_0 \le N, 1 \le A_1 \le B_1 \le L_1 \le N).

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

6 1 2 3 1 1 2

Sample Output

010101

Problem translated to English by Alex.


Comments

There are no comments at the moment.