#CCBCHBAHAI0000121. Mảng không thể gán toàn bộ bằng dấu = (Whole-Array Assignment Is Not Allowed)
Mảng không thể gán toàn bộ bằng dấu = (Whole-Array Assignment Is Not Allowed)
Whole-Array Assignment Is Not Allowed
Source: C Primer Plus
Version: Phuoc Hung OJ Extended
Problem Statement
In C, an actual array object is not a value that can be assigned as a whole with the = operator after declaration. If a and b are arrays of the same size, a statement such as a = b; is invalid. In contrast, an individual element such as is an ordinary integer object and can be assigned. To copy all elements of b into a, the program must copy the elements individually or use an appropriate library operation.
This task models three operation types on integer arrays and , each containing elements indexed from to :
- Type
1 i x: assign . This assignment is valid and changes . - Type
2: represent an attempted whole-array assignmentA = B. This is invalid in C and does not change the simulated data. - Type
3: copy every element of into , so after the operation for all . This operation is valid.
For every operation, print whether it is valid. After all operations, print the final state of .
Input
- The first line contains .
- The second line contains integers .
- The third line contains integers .
- The fourth line contains .
- Each of the next lines describes one operation in one of the forms
1 i x,2, or3. For a type-1operation, is guaranteed.
Output
For each operation, print one line:
VALIDfor an element assignment or an element-by-element copy;INVALID_ARRAY_ASSIGNMENTfor the attemptedA = Boperation.
After the result lines, print A = a0 a1 ... a(n-1) containing the final array .
Subtasks
Subtask 1 (100 points): , , .
Examples
Input
4
1 2 3 4
10 20 30 40
4
1 2 99
2
3
1 0 -5
Output
VALID
INVALID_ARRAY_ASSIGNMENT
VALID
VALID
A = -5 20 30 40
Explanation
Initially and .
Operation 1 2 99 assigns one element, so it is valid and changes to .
Operation 2 represents A = B. Whole-array assignment is invalid in C, so the simulated array does not change.
Operation 3 copies the elements of one by one, producing .
Finally, 1 0 -5 sets , so the final array is .