SEQ1 - 01 Sequence

no tags 

The input consists of exactly 5 test cases in the following format:

Input

N A0 B0 L0 A1 B1 L1 [3<=N<=1000,1<=A0<=B0<=L0<=N,1<=A1<=B1<=L1<=N]

Output

Exactly 5 lines,each contains:

a) A N-character sequence (We name it S) consisting of only characters '0' and '1' and no extra whitespaces, which satisfy the following conditions:

  • The number of '0' in any consecutive subsequence of S whose length is L0 is not more than B0 and not less than A0.
  • The number of '1' in any consecutive subsequence of S whose length is L1 is not more than B1 and not less than A1.

or

b)A single number -1,if the sequence which satisfies the conditions above doesn't exist.

Example

Input:
6 1 2 3 1 1 2
[and 4 test cases more]

Output:
010101
[and 4 test cases more]

hide comments
JackDavid127: 2012-12-01 17:07:29

It's a great problem.I learnt more from it.
C[i] - C[i-1] <= 1 (1<=i<=N)
C[i-1] - C[i] <= 0 (1<=i<=N)
C[i-L1] - C[i] <= -A1 (i-L1>=0)
C[i] - C[i-L1] <= B1 (i-L1>=0)
C[i] - C[i-L0] <= L0-A0 (i-L0>=0)
C[i-L0] - C[i] <= B0-L0 (i-L0>=0)

Last edit: 2010-03-25 14:44:20

Added by:Fudan University Problem Setters
Date:2007-04-01
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: C99 ERL GOSU JS-RHINO
Resource:Chinese National Olympiad in Informatics 1999,Day 1; translated by Blue Mary