blob: 2816c2bda1ebd97afd11928134d5e319bd18ce57 (
plain)
1
2
3
4
5
6
7
|
template<typename BidirectionalIterator> // Coordinate compression
void compress(BidirectionalIterator first, BidirectionalIterator last) {
vector<pair<BidirectionalIterator, int>> tmp;
for (auto it = first; it != last; ++it) tmp.emplace_back(*it, it-first);
sort(begin(tmp), end(tmp));
for (auto it = begin(tmp); it != end(tmp); ++it) (first+it->s) = it-begin(tmp);
}
|