Min Flip

0

0 votes
Very-Easy
Problem

You are given three binary sequence a, b, and c of n bits. You have to flip minimum bits in a and b such that the xor of a and b is equal to c. But there is a constraint that you can only flip atmost p bits of a and atmost q bits of b. If not possible then print -1.

Input:
First line consists of 3 space separated integers denoting n, p and q.
Each of the following 3 lines consists of binary sequences denoting a, b and c respectively.

Output:
Print a single integer denoting the minimum number of flips required.

Constraints
1<=n<=10^6
0<=p<=10^6
0<=q<=10^6

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?