#B2103. Image Similarity Calculation

    ID: 11185 Type: Default 1000ms 256MiB

Image Similarity Calculation

Image Similarity Calculation

Given two black-and-white images of equal size represented as a \(0-1\) matrix, compute the similarity between them.

Definition: Two corresponding pixels are considered similar if they have the same value. The similarity between the two images is defined as the percentage of pixels that are the same, i.e., \[ \text{Similarity} = \frac{\text{Number of matching pixels}}{\text{Total number of pixels}} \times 100\%. \]

inputFormat

The input begins with two space-separated integers \(n\) and \(m\) representing the number of rows and columns of the images respectively. The next \(n\) lines each contain \(m\) integers (0 or 1) representing the first image. This is followed by another \(n\) lines, each containing \(m\) integers (0 or 1) for the second image.

Example:
2 2
0 1
1 0
0 1
1 1

outputFormat

Output a single line containing the similarity percentage of the two images formatted to two decimal places.

Example:
75.00

sample

2 2
0 1
1 0
0 1
1 1
75.00