Tier and Rank
Time limit1sMemory limit256 MB
Given tiers that split N ranked users into tiers and subtiers, find the min and max rank a bragged tier can have, or report invalid or liar.
- Level
Medium6 of 10
- Topics
- Implementation, Math, Simulation
- Solved
- No attempts yet
Problem
Seongeun entered university. She never played games herself, but her friends kept bragging about their tiers in the popular game "Legend Legend", and she grew curious. A tier is a rating system that reflects a player's skill, based on the player's rank. When the game has users, their ranks are distinct integers from to .
The tier assignment process is recursive. Among the users who do not have a tier yet, the highest-ranked users are assigned the top tier first, and the remaining users move on to the lower tiers. Depending on how the top users are selected, a tier is either a fixed tier or a relative tier. When users still have no tier, each tier accepts the following number of users.
- Fixed tier accepting users:
- Relative tier accepting %: ( is the greatest integer less than or equal to )
From the top tier down, each tier takes the number of users it accepts, and the process moves on to the next tier. If some users still have no tier after every tier is processed, the system is invalid.
Each tier is split into four subtiers to separate players within the same tier. Each subtier is named by appending 1, 2, 3, or 4 to the tier name, and a smaller number means a higher subtier. If a tier has users, each subtier accepts at most users. Users are placed in rank order, starting from the highest subtier and filling each one to its maximum before moving to the next.
Input
The first line contains the number of users and the number of tiers , separated by a space. (, )
From the second line through the -th line, the tier information is given from the top tier down. Each tier name is a string of up to English letters, uppercase or lowercase, and all tier names are different.
- Fixed tier: the tier name and the maximum number of users it accepts, separated by a space. ()
- Relative tier: the tier name, a space, and a percentage in the form "%". is the percentage of the users who still have no tier at the moment this tier is assigned. ()
The last line gives the tier (or subtier) that the friend bragged about. It is either a tier name alone, or a tier name followed directly by a digit from 1 to 4.
Output
If the tier system cannot assign a tier to every user, print Invalid System on the first line. Otherwise, if the friend's tier cannot be a real user's tier in this system, print Liar. If the system is valid and the friend's tier is possible, print the minimum and maximum rank the friend can have, separated by a space, in that order.