#CCBCHBAHAI0000042. Xóa tất cả phần tử bằng x (Remove All Occurrences of x)
Xóa tất cả phần tử bằng x (Remove All Occurrences of x)
Xóa tất cả phần tử bằng x (Remove All Occurrences of x)
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem
Given an integer array and an integer .
Remove all elements equal to while preserving the relative order of every remaining element.
Define
Suppose
$$I=\{i_0,i_1,\ldots,i_{m-1}\},\qquad i_0<i_1<\cdots<i_{m-1}.$$The result has length and
Print the logical size and the array .
Input
The first line contains integers and . The second line contains exactly integers .
Output
Print on the first line. If , print on the second line.
Subtask
Subtask 1 (100 points): ; ; .
Example
Input
8 3
3 1 3 2 3 4 3 5
Output
4
1 2 4 5
Explanation
The indices whose values are not are , so the result in the original relative order is with size .