A game called Bocce played on a Cartesian grid
Bocce, as far as I know it, counts all the balls of one player that are closer to the jack than the closest one of his opponent.

That would mean that the distances from origin are irrelevant, instead, you need the distances from the balls to the jack:

auto dx = ball.x - jack.x;
auto dy = ball.y - jack.y;
auto distance2 = dx*dx + dy*dy;


Note that I avoided std::pow in favour to multiplying with itself, as std::pow inefficient for this purpose.

Note, too, that as the root function is strictly monotonely rising, you don't need to calculate it, but you can compare the squares as well and still will get the same results.

I personally strongly recommend that you create a class Ball containing three members: x, y for the coordinates and distance for the distance to jack:

class Ball
{
     int x, y;
     int distanceToJack2;
};


I'm not too happy with int as data type - it depends on the range of valid coordinates, though, if it is suitable or not. Assuming we have 32-bit int, then if the valid ranges for x and y can be covered with 16 bit, you will be safe from overflow while multiplying (this would yield undefined behaviour!), otherwise you'd need to calculate in next larger data type. For selecting the correct data types more safely, you might prefer the data types from &lt;cstdint&gt; header, e. g.:

 int32_t x, y;
 int64_t distanceToJack2;


Or you simply have coordinates and distance in double right away. Be aware that with double, you can quickly get issues due to rounding, so if you compare for one value being less than the other, you should consider them only so if difference is larger than some yet to be defined epsilon value (minimum distance for two values for not considering them equal). You could get some hints to from this question. Sure, it is java, but as long as both C++ and Java follow IEEE 754 for floating point values, it applies for both languages equally. On the other hand, you could then use std::hypot for calculating the distances in a very safe manner (thanks Toby for the hint).

Then you might add:

 void Ball::calculateDistance(Ball const&amp; jack)
 {
     uint64_t dx = static_cast&lt;uint64_t&gt;(x) - jack.x;
     uint64_t dy = static_cast&lt;uint64_t&gt;(y) - jack.y;
     distanceToJack2 = dx*dx + dy*dy;
 }


Finally, you can sort your balls according to the distances to jack and select all balls from one vector of which the distance is smaller than the distance of the first element in the respective other vector.

One last point: std::string is a rather bad key type for the map if you only have two fix values (beware of typos, additionally, map mangement is rather expensive). You might prefer an enum instead: enum class Color { RED, BLUE }; and use this one as key instead. Even better: don't use a map at all, instead:

std::string bocce(std::vector&lt;Ball&gt;&amp; red, std::vector&lt;Ball&gt;&amp; blue, Ball const&amp; jack);


Note that as you need to calculate the distances, which are stored in the balls, you cannot have const references for the two vectors (which otherwise would have been preferrable). From point of view of design, this is at least questionable (but at least, it's quite some improvement already). Ideally, the design would allow to pass in const vectors, but that would require some overhead, so for pragmatism, we might decide to live with the current design...