Question: Give a C + + solution 1 . Disaster Recovery Your company has been using an archaic repository management system and is switching to a
Give a C solution
Disaster Recovery
Your company has been using an archaic repository management system and is switching to a modern version control system. Unfortunately, much of the repositories' states were lost in the process of upgrading! Fortunately, you have a global log of "commits" applied to each repository that can be used to reconstruct much of the commit histories.
Each log entry corresponds to a commit applied to a particular repository and consists of a globally unique nonnegative integral commit id the nonnegative integral timestamp of the commit, and the files changed in the commit. Each of these files is described by its path and an opaque identifier that's a function of the path and repository. Two commits for different repositories may contain the same file path, but the file's opaque identifier should be distinct, and viceversa. And you may assume neither a file's path nor its opaque identifier contain whitespace.
To recover the commit histories, commits need to be combined to more accurately describe the set of commits applied to each repository. Commits can be combined with other commits containing at least one matching file path and opaque identifier. For example, the log below describes two repositories, where the first and last entries describe one of those two repositories:
id timestamp includefooh daa includebarh efe id timestamp includebazh ed
id timestamp includebarh efe srcbarcpp bff
The following log however, is considered ambiguous because foo. py has conflicting opaque identifiers of acf and ca but the three commits could otherwise be combined based on bar. py and baz. py:
id timestamp foopy acf barpy db
id timestamp barpy db bazpy fdc id timestamp baz.py fd foo.py fca
While the investigation is ongoing to better understand how the repositories' states were lost, you would like to provide employees with a tool to query commit histories based on the logs Specifically, queries are parameterized by a start timestamp, end timestamp, file path, and opaque identifier. The response for each query is the commit id of each commit corresponding to the repository referenced by the query's file path and opaque identifier, sorted by increasing timestamp followed by increasing commit id and filtered by the start and end timestamps, inclusive. Note that repositories should be determined based on all commits, not just the commits in the start and end timestamp range.
Input
Input is provided via standard input. The first line of input consists of a single integer N representing the number of lines that follow, one per line N Each line is either a valid log entry, or malformed.
Valid log entries consist of a line of words, delimited by a single space character.
Each word does not contain any whitespace.
Each two consecutive words make up a keyvalue pair and the first two keys are always id followed by 'timestamp'.
Keys are always unique within a line.
The commit id and timestamp values are always nonnegative bit integers. All other words are opaque strings.
Commit IDs are guaranteed to be unique across lines.
Bonus: detect and discard malformed log entries that don't follow this format.
After the N log entries is another line consisting of a single integer R representing the number of queries that follow, one per line R Each query is a spacedelimited sequence of start timestamp, end timestamp, file path, and opaque identifier.
Output
Output should be sent to standard output. If there are ambiguous log entries, the output should consist of a single line: AMBIGUOUS INPUT!. Recall that malformed log entries should be discarded and do not directly result in ambiguity. Otherwise, the output should consist of R lines, where each line is the spacedelimited response to the associated query with a trailing space. As described above, each response consists of the commit ids for the repository associated with the query parameters, sorted by increasing timestamp followed by increasing commit id and filtered by the start and end timestamps, inclusive.
Regardless of whether the input is ambiguous, your program should always exit
Sample Input
id timestamp quicksort.cpp ad mergesort.cpp cadel bubblesort.cpp ddl
id timestamp array.h sequence.h df
id timestamp mergesort.pp Ocddel bogosort. cpp ff
id timestamp array.h vector.h fccaf
id timestamp bubblesort.cpp ddl bogosort.cpp ff
id timestamp bubblesort.cpp eafa bogosort.cpp flaa
quicksort.cpp adO
vector.h fecaf
nofound.h empty response
bogosort.cpp ff
Sample Output
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
