Index: lib/typical/coordinate_compression.cpp ================================================================== --- lib/typical/coordinate_compression.cpp +++ lib/typical/coordinate_compression.cpp @@ -1,17 +1,20 @@ -// Convert a list of distinct elements to [0..N), preserving the original order. -// O(N log N), but doesn't incur the overhead of std::map. -// Tested: TCO 2012 R2C Mid +// Convert a list of N elements with K distinct elements to [origin .. origin+K), +// preserving the original order. O(N log N), but doesn't incur the overhead of std::map. +// Tested: TCO 2012 R2C Mid, SRM 584 Mid template -std::vector compress(std::vector& xs) +vector compress(const vector& xs, int origin = 0) { - std::vector< pair > xi; + vector< pair > xi; for(int i=0; i result(xs.size()); - for(int k=0; k result(xs.size()); + for(int k=0,id=origin; k