Orphan Backups
Time limit1sMemory limit1024 MB
Given a list of backup image names and a list of backup file names, print the files with no index entry and the index entries with no files, each sorted.
Problem
GigantoCorp has removed all tape drives from its data center and now does all of its backups to disk storage. However, it appears to use more disk space than its backup software reports. The company suspects that some files on the backup storage are missing from the backup software index. Write a program that checks whether the backup storage has "orphan" files that are not in the index, or "orphan" index entries that have no matching files on the backup storage.
Input
The input has two blocks.
The first block is a list of backup image names, one per line. Each name is 1 to printable ASCII characters with no spaces. There may be up to images. Names are unique and may appear in any order.
The block ends with an empty line.
The second block is a list of backup file names, one per line, left justified. Each file name has the format
imageName_integer_type
where imageName is a backup image name as described above, integer is an integer from to giving the time in seconds since January 1, 1970 at 00:00 GMT (the UNIX epoch), and type is a string of 1 to 6 uppercase letters. There may be up to file names. File names are unique and may appear in any order.
The second block ends at the end of the file.
Output
First, print each file that has no index entry, one per line, as the character "F", a single space, and the file name. After all orphan files, print each orphan index entry, one per line, as the character "I", a single space, and the image name. Print each list in ASCII lexicographic order.
If every file has an index entry and every index entry has at least one file, print only the line "No mismatches.".