I'll show you how to make vector operations faster. Call v.reserve(n) before adding n elements to avoid repeated reallocations. Each reallocation copies the entire vector to new memory, which is slow for thousands of elements.
Pass vectors by const reference to functions to skip copying. Use emplace_back(args) instead of push_back for complex objects because it constructs in-place without temporary copies.
Avoid insert() and erase() in the middle of large vectors because they shift all following elements. If you need frequent middle insertions, use a list instead of a vector.