UVa icon indicating copy to clipboard operation
UVa copied to clipboard

Insufficient comparator

Open GauthamBanasandra opened this issue 6 years ago • 0 comments

https://github.com/morris821028/UVa/blob/080fb3ae4b73ee81bbf11811c9ab48f69fc0f894/volume117/11729%20-%20Commando%20War.cpp#L7-L9

The above code fails to provide consistent sorting order when y is the same for different x. For example - 3 3 10 2 10 1 10

Comparator must be - if(a.y == b.y) { return a.x < b.x; } return a.y > b.y;

GauthamBanasandra avatar Sep 13 '18 17:09 GauthamBanasandra