#C9653. Construct Alternating String

    ID: 53770 Type: Default 1000ms 256MiB

Construct Alternating String

Construct Alternating String

You are given two integers \(K\) and \(M\). Your task is to construct a string of length \(K\) consisting solely of the characters X and Y such that:

  1. The string contains exactly \(M\) occurrences of the character X.
  2. No two adjacent characters are identical.

If it is impossible to construct such a string under the given conditions, print IMPOSSIBLE instead.

For example:

  • For \(K=5\) and \(M=3\), one valid answer is XYXYX.
  • For \(K=5\) and \(M=4\), it is impossible, so the output should be IMPOSSIBLE.

Note: The feasibility condition can be expressed mathematically as follows: In order for a valid string to exist, it must be that \(M \leq \lceil \frac{K}{2} \rceil\).

inputFormat

The input is given in a single line from stdin containing two space-separated integers:

  • K: the total length of the string to be constructed.
  • M: the exact number of occurrences of the character X required in the string.

outputFormat

Output a single line to stdout containing the constructed string if it is possible to satisfy the given requirements. Otherwise, output IMPOSSIBLE.

## sample
5 3
XYXYX

</p>