Kattis challenge to finding the number of different elements in a set
As you yourself hinted in the question title, you should be using a set. Discarding duplicates using a set is easier and more efficient than using a vector.