#P5033. Minecraft Parkour Challenge
Minecraft Parkour Challenge
Minecraft Parkour Challenge
Steve is trying his luck on a 2D parkour track inspired by Minecraft. The track consists of n blocks. Each block has a height and may be a special block. A player starts on the first block with an initial health of \(20\) points. If the health ever drops to \(0\) or below, the finish cannot be reached.
Falling Damage
- When moving from a block with height \(h_i\) to a block with height \(h_j\) and \(h_i > h_j\), the falling distance is \(d = h_i - h_j\). If \(d \le 3\) no damage is incurred; if \(d \ge 4\) then the player suffers \(d-3\) points of damage.
- If the landing block is a spider web, no falling damage is taken.
Jumping
- Jump Type A (with upward ability): From a block, the player may jump forward by 1 to 3 blocks. In this jump, the destination block’s height must be at most \(h_i+1\) (i.e. up by at most 1 block). If the destination block is lower than the current block, falling damage is applied as described.
- Jump Type B (horizontal only): The player may jump forward by 1 to 4 blocks, but the destination block must not be higher than the current block (i.e. no upward movement is allowed).
- When falling, the horizontal position does not change unexpectedly; you always land exactly on the destination block.
Special Blocks
- Slime Block: Upon landing normally on a slime block, there are two choices:
- Hold Shift: Land normally (and take falling damage if any, as usual).
- Do not hold Shift: Instead of stopping, the player bounces. The bounce height is \(\lfloor0.6\times d\rfloor\), where \(d\) is the falling distance from the jump. After reaching the apex, the player is forced to move forward exactly one block (i.e. from block \(j\) to block \(j+1\)). Upon landing from the bounce, falling damage is recalculated based on the bounce height (again, no damage if the difference is \(\le 3\)); if the landing block is a spider web, the bounce landing inflicts no damage.
- Spider Web: Landing on this block cancels all falling damage. In both normal and bounce landings the damage is 0.
The finish is the last block. Your task is to determine whether Steve can reach the finish. If he can, output the minimum number of jumps (only deliberate jumps count; bounce moves are automatic). If not, output qwq
.
inputFormat
The first line contains an integer n representing the number of blocks. Each of the next n lines contains an integer H (the height of the block) and a string T (the block type), separated by a space.
The block type can be one of the following:
normal
slime
web
The first block is the start and the n-th block is the finish.
outputFormat
If Steve can reach the finish block with his remaining health > 0, output the minimum number of jumps required. Otherwise, output qwq
.
sample
5
20 normal
20 normal
20 normal
20 normal
20 normal
1
</p>