← 返回 openai 的题目列表Monster Duel
类型:online_judge
Suppose you are participating in a monster duel game. Each monster has different attributes and attack power. The game rules are as follows:
Each monster has a primary attribute and several secondary attributes, with certain attributes that can be advantageous or disadvantageous against others.
When one attribute restrains another, the attack power is doubled; conversely, when restrained, the attack power is halved.
In a battle, players must determine the optimal attack strategy based on the attributes of their monster and their opponent's.
Write a program to calculate the optimal attack strategy for a given monster duel setup to achieve maximum damage output. Consider multiple attack types and attribute advantages.
Input Format:
The first line contains n, the number of monsters.
The next n lines, each containing a monster's attribute and attack power separated by a space.
Next line contains m, the number of advantageous attribute relationships.
The following m lines each describe two attributes where the first is advantageous over the second.
Output Format:
Output a list ensuring each monster selects the appropriate attack strategy and returns the maximized damage value.
Sample Input:
3
fire 100
water 80
wood 90
2
fire water
water wood
Sample Output:
['fire', 'water', 'wood']
Constraints:
The number of monsters does not exceed 100.
Each monster's attack power is a positive integer.
Each advantageous attribute relationship is unique, with a total not exceeding 200.
Example
Input
3
fire 100
water 80
wood 90
2
fire water
water wood