#P3972. [TJOI2014] 电影评分
[TJOI2014] 电影评分
Description
Xiao Z invented a new movie rating system with three kinds of operations: releasing a new movie, rating a movie, and querying a movie’s rank.
- When releasing a new movie: if none of its leading actors have appeared before, the new movie’s rating is . Otherwise, its initial rating equals the rating of the most recent previously released movie that shares at least one leading actor with it.
- When rating a movie: its rating becomes the average of its previous rating and the new score.
- When querying a rank: output the ID of the movie whose current rank is . The highest rating ranks first. If multiple movies have the same rating, the one released earlier ranks higher. All ratings are between and .
Input Format
The first line contains , the number of operations. Then lines follow, each being one of the following:
- Q x: query the movie ID currently ranked .
- R ID x actor1 actor2 ... actorx: release a new movie with ID , which has leading actors .
- C ID score: rate movie with the score ; the movie’s new rating becomes the average of its previous rating and .
Additional rules:
- All movie IDs are distinct.
- Each movie has at most leading actors.
Constraints:
- .
- .
- For of the testdata, .
- For of the testdata, .
Output Format
For each query operation, output the corresponding movie ID.
10
R 1 1 1
R 2 2 1 2
C 2 2
R 3 1 2
Q 1
C 3 2
C 1 5
Q 1
Q 2
Q 3
2
1
3
2
Hint
- The initial rating of a new movie is if none of its leading actors have appeared before; otherwise, it equals the rating of the most recently released earlier movie that shares at least one leading actor.
- After a rating operation C ID score, the new rating becomes the average of the current rating and .
- If multiple movies have the same rating, the earlier released one ranks higher. For example, if Movie and Movie have the same rating, then a query Q returns because Movie was released earlier.
Translated by ChatGPT 5
京公网安备 11011102002149号