Skip to content
Snippets Groups Projects
Commit 7acd6847 authored by Fernando K's avatar Fernando K
Browse files

Simplifica algoritmo de mo

parent 447f7f9a
No related branches found
No related tags found
No related merge requests found
vector<int> mo(vector<qry> qs) { vector<int> mo(vector<qry> qs) {
vector<int> ans (qs.size()); vector<int> ans (qs.size());
sort(qs.begin(), qs.end(), [](qry a, qry b) { sort(qs.begin(), qs.end(), [](qry a, qry b) {
if (a.l/B != b.l/B) if (a.l/B != b.l/B) { return a.l < b.l; }
return make_pair(a.l, a.r) < make_pair(b.l, b.r);
return (a.l/B) % 2 ? a.r < b.r : a.r > b.r; return (a.l/B) % 2 ? a.r < b.r : a.r > b.r;
}); });
int l = 0, r = -1; int l = 0, r = -1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment