#C2439. Attendee Seat Reassignment
Attendee Seat Reassignment
Attendee Seat Reassignment
In this problem, you are given multiple datasets representing seating arrangements at an event. Each dataset consists of two seating arrangements: the initial seating and the target seating. The task is to compute the minimum number of moves required to convert the initial seating arrangement into the target seating arrangement.
For each dataset, you are given two integers n and m on the first line, where n is an auxiliary value and m is the number of seats. The next line contains m integers representing the initial seating arrangement, and the following line contains m integers representing the target seating arrangement. The input terminates with a line where both n and m are zero.
The minimum number of moves is defined as:
$$\text{moves} = \sum_{i=1}^{m} \mathbf{1}\{ initial[i] \neq target[i] \}, $$where \(\mathbf{1}\) is the indicator function (which is 1 if the condition is true, and 0 otherwise).
Your program should read from stdin
and write the result for each dataset to stdout
.
inputFormat
The input is read from stdin
and contains several datasets. Each dataset is structured as follows:
- The first line contains two integers n and m. (Note: n is not used in processing.)
- The second line contains m integers representing the initial seating arrangement.
- The third line contains m integers representing the target seating arrangement.
The end of input is indicated by a line where both n and m are 0.
outputFormat
For each dataset, output a single integer on a new line representing the minimum number of moves required to match the target seating arrangement.
The output is printed to stdout
.
3 5
1 0 1 0 1
0 1 0 1 0
2 6
0 0 1 1 0 0
1 0 0 1 0 1
0 0
5
3
</p>