Update util.cpp

This commit is contained in:
Anthony Wang 2019-08-06 14:35:23 -05:00 committed by GitHub
parent 2ffa010d79
commit 585ac8606d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,7 @@
template <class BidirectionalIterator> // Coordinate compression
void compress (BidirectionalIterator first, BidirectionalIterator last) {
vector<int> tmp(first, last);
void compress(BidirectionalIterator first, BidirectionalIterator last) {
vector<auto> tmp(first, last);
sort(tmp.begin(), tmp.end());
tmp.resize(unique(tmp.begin(), tmp.end()) - tmp.begin());
for (auto it = first; it != last; it++) *it = lower_bound(tmp.begin(), tmp.end(), *it) - tmp.begin();
for (auto it = first; it != last; it++)* it = lower_bound(tmp.begin(), tmp.end(), *it) - tmp.begin();
}