Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A certain video game hosts a massive multiplayer online tournament for a week. During that period, players may enter at any time. There is no

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

A certain video game hosts a massive multiplayer online tournament for a week. During that period, players may enter at any time. There is no requirement that the two opponents in any contest have played the same number of matches prior. Each participant receives 10 points just for entering the tournament. They accumulate points by winning matches. Players are eliminated after their first loss. Each player has an associated level. Initally all players start at level 1 . Winning one match promotes a player to level 2; winning 2 matches after being promoted to level 2, promotes the player to level 3 , and so on. In general, a player at level i who wins i matches gets promoted to level i+1. As an incentive to start the tournament early, the orgnizers have come up with an innovative scoring system. After each match, the winner earns points determined by the formula: winnerpoints=20%winnerlevelloserpoints As players participate, they accumulate points until they are eliminated. By the end of the tournament, a total of n players have entered; they are referred to as p1,p2,,pn. A query is generated for q of them, pi1,pi2,,piq requesting their final scores. Given the history of the outcomes of all the matches within the tournament, determine the number of points earned by the q participants of the query. Output their scores in the order given, each on a separate line. Input Format Line 1: n q Line 2: i_1 i_2 ... i_q q space separated integers denoting the indexes of the players being queried The next n lines present the history of wins in the following way. Each line is in the format: i j_1 j_2 ... j_w to indicate that player pi defeated w players, in the order pj1,pj2,pjw. (A player who defeated no other players will have only their index on their line) Constraints 10n1051qn Output Format q lines, each containing a single integer indicating the score earned by the corresponding player identified in the query. Sample Input 0 52123453153541 Sample Output 0 There are 5 players in total, and we are asked to report on the scores for players 2, 1 and 5 . Observing the history of matches, we see that Player 1 did not defeat anyone, so we know that that player will end with 10 points (everyone gets 10 to start with). Player 2 defeated players 5 and 4 , in that order, but we don't know how many points were earned from those players until we look at their win records as well. Player 5 defeated players 3 and 1 . Player 3 defeated no one, so they must have had only their 10 points on entry when they lost to player 5 . So, player 5 would have earned 20%110=2 points for defeating player 3. That win would promote player 5 to level 2 . So, when they competed against player 1 next, their multiplier was 2 . We have already ascertained that player 1 had only 10 points, so player 5 earns 20%210=4 points from defeating player 1 . In total, player 5 earned 2+4=6 points, so they would have had a total of 16 points when they lost to player 2. Now we are ready to calculate player 2's points earned. Defeating player 5 was player 2's first match, so player 2 was still at level 1 , and they would have earned 20%116=3 points from it, after which they would have been promoted to level 2 . We see that player 4 did not defeat anyone, so we know that they would have had 10 points when they lost to player 2 , and therefore player 2 earned 20%210=4 points from that match. In the end, player 2 would have received 10+3+4=17 points. So, the answers to the queries for players 2, 1 and 5, in that order, were 17, 10 and 16 , each of which we output on a separate line

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

6th International Edition

061921323X, 978-0619213237

More Books

Students also viewed these Databases questions