20. Sequence compression using std::map and std::vector

C++ Medium STL

Task «20. Sequence compression using std::map and std::vector»

Given a sequence of integers. It is necessary to perform compression of the sequence: replace each number with its ordinal number at the first occurrence (starting from 1). The ordinal numbers must be unique for each number. Use `std::map` to store the mapping of the number and its ordinal number, and output the result in the order of the original sequence.

Input Format

In the first line, an integer N (1 ≤ N ≤ 10^6). In the second line, N integers separated by spaces, the values of the numbers range from -10^9 to 10^9.

Output Format

Output N integers — the sequence numbers for each number in the original sequence, separated by a space.

Examples

Example 1

INPUT
5 1 2 1 3 2
OUTPUT
1 2 1 3 2

Example 2

INPUT
2 1 3.0 2 4.0 5.0
OUTPUT
28.27 20.00

Example 3

INPUT
3 100 100 100
OUTPUT
1 1 1

Example 4

INPUT
1 2 2.5 3.5
OUTPUT
1

Example 5

INPUT
6 ADD Write report 3 ADD Fix bug 5 ADD Update docs 2 PENDING COMPLETE Fix bug PENDING
OUTPUT
Fix bug, Write report, Update docs Write report, Update docs
main.cpp