2990 - CS2351_DS_24Spring_Quiz2 Scoreboard

Time

2024/04/15 18:30:00 2024/04/15 20:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team
1 14294 - Badge Quest: The Multiverse Challenge. judgeDS_2018 We have change the order of image for your better comprehension. Plz press F5. judgeDS_2018 2024/04/15 19:16:29

# Problem Pass Rate (passed user / total user)
14294 Badge Quest: The Multiverse Challenge.

14294 - Badge Quest: The Multiverse Challenge.   

Description

 

You are a renowned Pokémon trainer known for collecting battle badges worldwide. Now, you face the final gym challenge to earn your last badge in the ultimate test of skill and strategy – "Badge Quest: The Multiverse Challenge."

The gym leader detests conventional battles and prefers a game with flair, spanning across the multiverse. He challenges you and your partner Mewtwo to this intricate game, where each list represents a different dimension or realm within the multiverse. If you emerge victorious, you'll claim the final badge, proving your mastery over not just one, but multiple dimensions.

Beside you stands Mewtwo, your loyal partner, his keen intellect and formidable power serving as valuable assets in this daunting task. As you both prepare to face the challenge ahead, Mewtwo's unease is palpable. "Do you think we're prepared for this, Trainer?" he inquires, his voice tinged with uncertainty. 

You meet Mewtwo's gaze with a reassuring smile, your confidence unwavering. "Nah, I'd win," you reply, your tone firm and resolute. " He is the challenger here."

With a nod of understanding between you, Mewtwo finds solace in your unwavering belief. With your bond strengthened and determination steeled, you both set forth to navigate the complexities of the multiverse and emerge victorious in this epic battle of skill and strategy.

Summary:

Given n lists representing different dimensions and x commands, determine the final arrangement of Pokémon after executing the operations across the multiverse.

 

Commands:

  • Insert int1 int2 int3: Summon a Pokémon into the list at index int1. The Pokémon's ID will be int2, and its level will be int3.
  • Remove int1 int2: Remove all Pokémon with the ID int2 from the list at index int1.
  • Rotate int1 int2: Rotate int2 times. With each rotation, the last node in the list at index int1 will be moved to the beginning of the same list.
  • Reorder int: Rearrange nodes based on their indices. In the list at index int, group all nodes with even indices together, followed by the nodes with odd indices, and return the reordered list.
  • Reverse int1 int2 int3: Reverse the order of Pokémon in the list at index int1 within the range of indices [int2, int3].
  • MergeListsPreserveOrder int1 int2: Merge the list located at index int2 into the list located at index int1, ensuring that the original order of elements in both lists is maintained. After merging, the elements from both lists will be combined into the list at index int1, with the order of insertion determined by comparing the elements. Elements from the list at index int2 will be inserted into the merged list before elements from the list at index int1 if their Level is smaller, if their level is equal, then the element that has a smaller ID can be inserted first. After merging, the list at index int2 will become empty.

Hint:

Finish simpler functions first, some test cases only require basic functions. Functions are ordered by difficulty.

Guarantee & Notes:

  • For the reverse command: The range specified by int2 and int3 will always be within the size of the list at index int1.
  • All indices are zero-based.
  • Even indices, inclusive of zero, are considered.
  • All lists are empty at the beginning.
  • All operations would be valid.

Explanations:

Given 3 lists after some operations.

 

Insert 1 1 1

Reverse 1 2 4

Remove 2 1

List at index 2 will become empty

 

Rotate 1 2

 

Reorder 1

Original -> {1, 2, 3, 2, 1},  Reordered -> {1, 3, 1, 2, 2}

 

MergeListsPreserveOrder 0 1

We will use different lists to demonstrate this operation for better understanding.

Before

After

Input

1. Frist line will consists of an integer n which indicates the total number of lists. Where n is (1 <= n <= 10)

2. Second line will consists of an integer x which indicates the total number of commands. Where x is (1 <= x <= 10000)

3. The following x lines will contain one of the following commands:

Insert int1 int2 int3 (0 <= int1 < n) (1 <= int2, int3 <= 100)

Reverse int1 int2 int3 (0 <= int1 < n) (0 <=int2, int3 < size of list at index int1)

Remove int1 int2 (0 <= int1 < n) (1 <= int2 <= 100)

Rotate int1 int2 (0 <= int1 < n) (1 <= int2 <= 10000 )

Reorder int1 (0 <= int1 < n)

MergeListsPreserveOrder int1 int2 (0 <= int1, int2 < n) (int1 != int2)

Output

Print out the List index and the pokemon ID and Level in this list.

If list is empty, print Empty.

Sample Input  Download

Sample Output  Download

Tags

linked list



Discuss