#P8471. Constructing a Multiple-Choice Answer with Exact Errors
Constructing a Multiple-Choice Answer with Exact Errors
Constructing a Multiple-Choice Answer with Exact Errors
You are given a multiple‐choice exam with \(2n\) questions. Each question has two options: \(\text{A}\) and \(\text{B}\). The correct answers are represented by a binary string \(s\) of length \(2n\): here, the character \(0\) corresponds to \(\text{A}\) and the character \(1\) corresponds to \(\text{B}\).
Your task is to construct an answer string \(p\) (also of length \(2n\)) such that:
- The answer string contains exactly \(a\) occurrences of \(0\) (i.e. exactly \(a\) answers \(\text{A}\)).
- The number of positions where \(p\) differs from \(s\) is exactly \(e\); in other words, \[ \sum_{i=1}^{2n} \left[ s_i \neq p_i \right] = e, \] where \([\cdot]\) denotes the Iverson bracket (equals 1 if the condition holds, and 0 otherwise).
If no such string exists, output -1
.
Note: For convenience, it is guaranteed that \(e \le n\).
inputFormat
The first line contains three integers \(n\), \(a\), and \(e\) (as described above).
The second line contains a binary string \(s\) of length \(2n\), representing the correct answers. Here, \(0\) represents \(\text{A}\) and \(1\) represents \(\text{B}\).
outputFormat
If a valid answer string \(p\) exists, output it. Otherwise, output -1
.
sample
3 3 2
010101
100101
</p>