#CCBCHBAHAI0000114. Thay tất cả x bằng y và đếm số lần thay
Thay tất cả x bằng y và đếm số lần thay
Replace Every x by y and Count Replacements
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem
Given and integers , assign for every index whose original value equals . Also compute . If , the array is unchanged but each matching position still counts as an activated replacement.
Input
Read , then the array, then .
Output
Print , then the modified array.
Subtask
Subtask 1 (20 points): .
Subtask 2 (30 points): .
Subtask 3 (50 points): , values within in magnitude.
Example
Input
6
2 5 2 7 2 9
2 8
Output
3
8 5 8 7 8 9
Explanation
Value 2 occurs three times, so three positions become 8.