I'll show you how unique(v.begin(), v.end()) removes consecutive duplicate elements. It returns an iterator to the new logical end of the range with duplicates removed. You must sort first to remove all duplicates: sort(v.begin(), v.end()) then unique().
Without sorting, only adjacent duplicates are removed and others remain. Use v.erase(unique(v.begin(), v.end()), v.end()) to resize the vector. Calling unique() alone just moves elements without changing the container's size.