It's $O(n^2 \cdot log(n))$ actually. It'll be $O(n^2)$ if use std::unordered_set instead of std::set
std::unordered_set
std::set
It's $O(n^2 \cdot log(n))$ actually. It'll be $O(n^2)$ if use
std::unordered_setinstead ofstd::set