#C2668. Book Recommendation System
Book Recommendation System
Book Recommendation System
You are given a list of books with their authors and a set of users with their book ratings. For each user, you must determine the book they rated highest (if there are ties, consider the one that appears first in the input). Then, from the same author of that book, you need to recommend a different book – specifically, the lexicographically smallest one among those not yet read by that user. If no such book exists, output No Recommendation.
The task involves using data structures to map authors to their books and process each user’s ratings accordingly.
inputFormat
The input is read from standard input with the following format:
- An integer n, the number of books.
- n lines follow, each containing a book title and its author separated by a space.
- An integer m, the number of users.
- For each user, the following lines are provided:
- A line containing the user name (string).
- An integer k, the number of ratings for that user.
- k lines follow, each with a book title and an integer rating, separated by a space.
outputFormat
The output should be written to standard output. For each user, output a single line with the recommended book title. If no recommendation can be made, output No Recommendation.
## sample5
BookA Alice
BookB Bob
BookC Alice
BookD Charlie
BookE Bob
2
User1
2
BookA 8
BookB 9
User2
2
BookA 5
BookD 7
BookE
No Recommendation
</p>