Misha and the Negative
InterviewTime limit2sMemory limit512 MB
Given two binary black-and-white images of the same size, count the pixels where the second image does not equal the negative of the first.
- Level
Easy2 of 10
- Topics
- Implementation, Array, String, Simulation
- Solved
- No attempts yet
Problem
Misha has already learned to take good photographs and recently became interested in programming. The first program he wrote produces the negative of a binary black-and-white image.
A binary black-and-white image is a rectangle made of pixels, each of which is either black or white. The negative of such an image is obtained by replacing every black pixel with white and every white pixel with black.
As a beginning programmer, Misha wrote his program with a mistake, so running it could produce an incorrect negative. To estimate how far the resulting negative deviates from the image, Misha began testing his program.
He used the original images as input data. He then carefully analyzed the negatives produced by the program, each time counting the pixels of the negative that were produced incorrectly.
The task is to write a program that takes a binary black-and-white image and the negative produced by Misha's program as input, and from them determines the number of pixels where a mistake was made.
Input
The first line of the input file contains the integers n and m (1 ≤ n, m ≤ 100), the height and width of the original image in pixels.
The next n lines describe the original image. Each line consists of m characters, «B» and «W». The character «B» corresponds to a black pixel and «W» to a white pixel.
Then comes an empty line, followed by a description of the image produced by Misha's program, in the same format as the original image.
Output
The output file must contain the number of pixels of the negative that Misha's program formed incorrectly.