#C5053. Minimum Moves to Transform Words
Minimum Moves to Transform Words
Minimum Moves to Transform Words
You are given an integer \(n\) followed by \(n\) words, and finally a target string. Each word has the same length as the target string. In one move, you may change a single character in one word. Your task is to compute the minimum number of moves required so that every word is transformed into exactly the target string.
The number of moves is defined as the total number of positions where the characters in a word differ from the corresponding character in the target string. Formally, if \(w\) is a word and \(t\) is the target string, then the moves required for \(w\) is:
[ \text{moves}(w, t) = \sum_{i=1}^{L} \mathbf{1}_{{w_i \neq t_i}}, ]
where \(L\) is the length of the word and \(\mathbf{1}_{\{w_i \neq t_i\}}\) is 1 if \(w_i \neq t_i\) and 0 otherwise. The output should be the sum of moves required for each word.
inputFormat
The input is read from standard input (stdin) and has the following format:
- An integer \(n\) indicating the number of words.
- \(n\) lines, each containing a word.
- A single line containing the target string.
It is guaranteed that each word has the same length as the target string.
outputFormat
Output a single integer on a line representing the minimum number of moves required to transform all the words into the target string.
## sample3
abc
acb
bac
bca
7