luogu#P5006. [yLOI2018] 大美江湖
[yLOI2018] 大美江湖
Background
Light snow falls on the long street, and the maple leaves turn red again each year.
I do not linger only for old friends; in fact, I also love Chang’an.
The footsteps outside the door are slow; I seem to see the familiar face from the past.
The story has gone through joys and sorrows many times, and every ending is related to you.
— Yin Lin, The Great Jianghu.
This problem was originally named Space Complexity.
Problem Description
While listening to The Great Jianghu, Fusu controls his character “Paojie” in JX3 and arrives in Chang’an.
In Chang’an there is a quest that requires Fusu to enter an underground “mechanism corridor”. The corridor map is a rectangular grid with rows and columns. Each cell contains some monsters or potions. Fusu controls Paojie wandering in the corridor. Sometimes he wants to ask you how much attack power, defense, and lost HP his character (Fusu) currently has.
There are three kinds of potions and one kind of monster on the map, represented by characters R, Q, Y, M, respectively. Specifically:
- Character
Rrepresents an HP potion, which can reduce Paojie’s lost HP by . If the currently lost is not greater than , then the lost HP becomes . - Character
Qrepresents a strength potion, which increases Paojie’s attack power by . - Character
Yrepresents a defense potion, which increases Paojie’s defense by . - Character
Mrepresents a monster, which will deal damage to Paojie.
Each monster has three attributes: HP , attack power , and defense . To reduce the workload of the validator reduce the difficulty, all monsters have the same attributes.
Once you step onto a monster cell, a battle starts. Fusu will definitely kill the monster, but the monster will also deal some damage to Fusu. Specifically, the damage dealt to Fusu is
$$\max(1, \left\lceil \frac{HP_0}{\max(1, ST - DE_0)}\right\rceil \times \max(1, ST_0 - DE))$$where means the larger of and , and is the smallest integer not less than . Values with subscript are the monster’s parameters, and values without subscripts are the character’s parameters.
You will receive operations. Each operation is either a query or a move.
For a move, you will be given an additional numeric parameter, which can only be one of , meaning that Paojie moves left/right/up/down on the map. Moving up means the row number decreases by one and the column stays the same; other directions are analogous.
For a query, you need to output how much HP Paojie has lost, and the current attack power and defense.
Note that if you enter the same cell multiple times, the potion in that cell will be picked up repeatedly, and the monster will appear again. That is, you may assume that after leaving a cell, it returns to its original state.
Also note that if there is a monster at the initial position, no battle occurs; if there is a potion at the initial position, it will not be picked up.
Input Format
Each test point contains exactly one set of testdata.
The first line contains two integers separated by spaces, representing the number of rows and columns of the map.
Lines to each contain a string of length . The -th character in line represents the item/creature in the cell at row and column . In particular, if is the character ., it means there is nothing there, but the cell is passable.
Line contains three integers separated by spaces, representing the monster’s HP , attack power , and defense .
Line contains two integers, representing the character’s initial row and initial column .
Line contains two integers separated by spaces, representing the character’s initial attack power and defense .
Line contains an integer, representing the number of operations .
Lines to each start with an integer , representing the type of this operation.
- If , this operation is a query.
- If , this operation is a move. After a space there will be an integer as the movement parameter.
Output Format
For each query operation, output one line with three integers separated by single spaces: the character’s lost HP , and the current attack power and defense .
5 5
MMMMM
RRRRR
QQQQQ
YYYYY
.....
5 5 5
5 1
10 10
8
2 3
1
2 3
2 3
2 3
1
2 2
1
0 10 15
1 15 15
2 15 15
Hint
Constraints
| Test Point ID | Special Property | |||
|---|---|---|---|---|
| None | ||||
| Guaranteed | ||||
| No monsters on the map | ||||
| None | ||||
For all test points, it is guaranteed that:
- , .
- .
- , .
- can only be one of
.,R,Q,Y,M. - During the entire movement process, the current row is always a positive integer not greater than , and the current column is always a positive integer not greater than .
Translated by ChatGPT 5