2977 - CS2351_DS_24Spring_HW2 Scoreboard

Time

2024/03/25 23:59:00 2024/04/14 23:59:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
14272 A Trainer's Final Battle

14272 - A Trainer's Final Battle   

Description

"I'm from Pallet Town, and this is my buddy, Kenjichu. My dream is to become a Pokémon Master!; I am here to challenge you!!"

YOU are a famous Pokémon trainer who has been collecting battle badges all over the world. Now you’re here to challenge the final gym for your last badge. Normally, you have to battle it out in a Pokémon battle to find the strongest one!. However, this gym leader hates regular battles and prefers it with some ‘styles’, hence he asks you and your partner Kenjichu to compete in a slightly different yet simple game with him, The Circle Game. If you can win against him, you will earn the final badge.

The rules of this game are very straightforward, Pokémons will be summoned onto the stage standing in a circle through commands. The gym leader will provide Kenjichu with a list of commands related to adjusting each Pokémon’s position; and the summoned Pokémons will be represented by their Pokédex ID. After reading the given commands and performing the required operations, Kenjichu will have to give a list of the remaining Pokémons who are still standing on stage in their correct positions.

Kenjichu shivers, he clearly is frightened, this challenge is different from typical battles he is used to.

“Huhh this is too EASY…is this even called a CHALLENGE!!?” You exclaimed.

Kenjichu looked you in the eyes and both of you nodded knowingly, HE TRUSTS YOUR abilities to swiftly solve this challenge with all his heart. <3

Summary: Given a total number of commands followed by a list of commands, please find the end result of the list after performing required operations. 

Commands:

Insert int1 int2 int3 string: Insert Pokémon with int1 Pokédex value, int2 damage value, int3 health value, and string stance. If there exists more than one Pokémon in the list, insert the Pokémon to the left of the current target. If there exists more than two Pokémons in the list then insert Pokémon with int value between the current target Pokémon and the Pokémon to the target’s left. When inserting Pokémons, they will take three of the following stances, Evolve, Attack or Neutral.

- Evolve stance, if the adjacent Pokémons to the inserted Pokémon are of the same type (Pokédex value) then they can evolve (merge into one and set its new health and attack value to the current highest value among them). However, each Pokémon can only evolve 2 times, i.e. if one of the adjacent Pokémon has already evolved to level ‘3’ then the inserted Pokémon cannot evolve (merge), when evolving take the Pokémon with the highest evolution level and increment from it. The evolved Pokémon becomes the current target. Base evolution level is 1 by default when initially inserted. If any requirements were not met, insert the Pokémon normally.

- Attack stance, the inserted Pokémon will attack its adjacent neighbors with int2 damage point. If the adjacent Pokémons health point is reduced to <= 0, they’re considered “put to sleep” and will be dragged out of the arena (remove them, if removed Pokémon is current target, hand current target over to the inserted Pokémon). If only one other Pokémon is in the circle, attack only once, double attack is unfair and considered a foul.

- Neutral stance, nothing will happen and Pokémon will be inserted normally.. After all necessary operations have been completed, inserted Pokémons will return to ‘Neutral’ stance.

 After all necessary operations have been completed, inserted Pokémons will return to ‘Neutral’ stance.

Delete: Remove the current target Pokémon. Assign the next Pokémon in the clockwise direction as the next target Pokémon if there’s more than one Pokémon in the list.

Shuffle char int: Traverse to the adjacent Pokémon in the list int times starting from the current target in a clockwise(char == ‘c’) or anti-clockwise(char == ‘a’) direction. Once complete, swap that Pokémon’s position with the current target Pokémon.

Check int: Starting from the target Pokémon and searching in the clockwise direction, remove any duplicates (Pokémons with same Pokédex value) found within the next int-1 Pokémons. If the current target is removed, assign the nearest unremoved Pokémon in the clockwise direction as a new target Pokémon.

Reverse int: Starting from the target Pokémon and counting in the clockwise direction. For every int Pokémons a group will be created. Then within each group, reverse their positions. Change the current target Pokémon to the Pokémon that replaces its position. 

Guarantees & Notes:

● First Pokémon added to the list when empty will be the initial target Pokémon.

● Delete will only occur when there’s at least one Pokémon in the list.

● Shuffle, Check, and Reverse will only occur when there’s two or more Pokémons in the list.

● Check distance will not exceed the current number of Pokémons in the list.

Explanation

Normally insert 1,2,3,3. (Neutral stance = do nothing)

We then delete the current target (‘1’).

 Shuffle clockwise by 4 steps.

 Now for the command ‘Check 4’.

For ‘Reverse’ the following is performed.

Note that reverse is performed to the whole list. And the list will be reversed by groups of given int size. If the group size exceeds the available node, ex: 6->7->8 and int = 4. Then just perform the reverse operation on the available nodes, i.e. 6->7->8, int = 4 becomes 8->7->6

Now let’s see how insert with special stances works, first off evolve stance: At first, we have two nodes marked as ‘3’ with level equals to ‘1’. However, there are not enough nodes thus evolution cannot occur. But then, another ‘3’ node is inserted as an ‘Evolve’ stance, this time an evolution is possible. Assign the evolved node as the new target.

 Now let’s see how ‘Attack’ stance works:

Input

1. First line will consist of an integer n which indicates the total number of commands.

    Where n is(1<=n<=10,000)

2. The following n lines will contain one of the following commands:

     Insert int1 int2 int3 string (1<=int1<=100) (1<=int2,int3<=1,000)

     Delete

     Shuffle char int (char is either ‘a’ or ‘c’ ) (1<=int<=100,000)

     Check int (2<=int<=no.ofPokémons)

     Reverse int (1<=int<=10,000)

Output

Print out the Pokédexvalues, remaining health, and evolution level of every remaining Pokémon in the circle starting from the current target, following the format: “ID: {id} HP: {health} LVL: {evolutionlevel}”

If no Pokémons exist, print:“no Poke Poke ;-;”

Enter a new line after every output.

Sample Input  Download

Sample Output  Download

Tags

linked list



Discuss