#C13462. Shallow vs Deep Copy

    ID: 43003 Type: Default 1000ms 256MiB

Shallow vs Deep Copy

Shallow vs Deep Copy

In this problem, you are given an array that consists of three elements:

  • An integer.
  • A nested list of exactly two integers.
  • Another integer.

You will also be given an operation type – either shallow or deep – which specifies the way you need to copy the array. Your task is to perform the copy accordingly:

  • For a shallow copy, only the outer list is copied, while the inner nested list is shared between the original and the copy.
  • For a deep copy, both the outer list and the inner nested list are duplicated.

After copying, modify the copied array by setting the first element of the nested list to 9. Finally, print the original array in a three-line format. Note that if you performed a shallow copy, the modification will affect the original array, while with a deep copy the original array remains unchanged.

inputFormat

The input consists of four lines:

  1. A string that is either shallow or deep indicating the copy operation.
  2. An integer representing the first element of the array.
  3. Two integers separated by a space, representing the two elements of the nested list.
  4. An integer representing the third element of the array.

All input is provided via standard input (stdin).

outputFormat

Output the original array after performing the copy and modification. The output should be printed in three lines:

  • The first line contains the first element (an integer).
  • The second line contains the two integers of the nested list separated by a space.
  • The third line contains the third element (an integer).

Output is given via standard output (stdout).

## sample
shallow
1
2 3
4
1

9 3 4

</p>