DWITE Online Computer Programming Contest, March 2010, Problem 3
Sometimes, when the files are different, we want to have a summary of how far off they are. In the case of well-formatted data, we might also want to know by how much the values differ. A practical example would be comparing some kind of a usage report against the expected values.
The input will contain 5 test cases. Each set starts with a line having an integer and another line with an integer . Followed by lines with the contents of the two files. There will be a line containing three minus signs ---
after each set.
Each line inside a "file" to be compared is a string-integer pair separated by a single space. The string is a 3 character word (lowercase alpha characters), the integer is a non-negative integer less than .
Each "file" is in a sorted order according to the leading string. The string keys in each file are unique.
The output will contain 5 lines, each containing a pair of integer sums, separated by a space. The first integer is the total number of lines missing between two files. The second integer is a sum of the absolute differences in the values of the lines where string keys match.
Notes on the sample below: In the first case, both files have just a single line. The keys are the same, so zero lines are missing, but the values differ by one. In the second case, the first file is missing a line with baz
while the second file is also missing a line with foo
, so there is a total of two missing lines. The remaining lines have their values differ by one.
Sample Input
1
1
foo 42
foo 41
---
2
2
bar 1
foo 42
bar 2
baz 40
---
Sample Output
0 1
2 1
Problem Resource: DWITE
Comments