Document Revision Manager
You are implementing a simple document revision system for a collaborative editor. The system must support creating and retrieving different versions of documents, and analyzing what changed between versions.
Implement a version-control manager that supports three operations:
-
EDIT
idcontent: Create or update the document at versionidwith the givencontent. If versionidexists, overwrite it; otherwise, create it. -
GET
id: Return the content stored at versionid. If the version doesn't exist, output"VERSION NOT FOUND". -
DIFF
id1id2: Compare the content of versionid1and versionid2. Output the number of lines that are different.
Input
The first line contains n (1 ≤ n ≤ 1000), the number of operations.
Each of the next n lines contains one operation:
EDIT <id> <content>: whereidis a positive integer (1 ≤ id ≤ 10^6) andcontentis a single line of text: 1 to 1000 characters, each an English letter (a-z,A-Z), a digit or a space, with no leading or trailing spaces and no two consecutive spaces. The content is everything after the space that followsid, and it may contain several words.GET <id>: whereidis a positive integer (1 ≤ id ≤ 10^6).DIFF <id1> <id2>: whereid1andid2are positive integers (1 ≤ id1, id2 ≤ 10^6).
Output
For each GET operation, output the content of the version or "VERSION NOT FOUND".
For each DIFF operation, output a single integer: the number of differing lines between the two versions.
Notes
- Each version stores a single line of text.
- When comparing two versions with DIFF, if the content is identical, the answer is 0. If they differ, the answer is 1 (since each version is one line, it either changed or stayed the same).
- If either version in a DIFF operation doesn't exist, treat it as an empty string.