#C165. Document Manager
Document Manager
Document Manager
Implement a Document Manager which supports two operations: adding documents with a unique identifier and associated keywords, and searching for documents by keyword.
The operations are as follows:
- ADD: Add a document with its doc_id and a list of keywords.
- SEARCH: Search for all documents that contain the given keyword. The matching document IDs should be output in lexicographical order (sorted order). If no document is found, output an empty line.
The input and output will be handled via standard input (stdin) and standard output (stdout).
inputFormat
The first line contains an integer Q, representing the number of operations. Each of the following Q lines is in one of the following formats:
ADD doc_id k keyword1 keyword2 ... keywordk SEARCH keyword
For an ADD operation, 'doc_id' is a unique identifier (a string without spaces), k is the number of keywords to follow, and then k keywords are provided. For a SEARCH operation, a single keyword is provided.
outputFormat
For each SEARCH command, output a single line with the document IDs that match the keyword, separated by a single space in lexicographical order. If no document matches, output an empty line.## sample
3
ADD doc1 3 python coding programming
SEARCH python
SEARCH java
doc1
</p>