#include <algorithm>
#include <iostream>
#include <vector>
using std::cout;
using std::endl;
using std::vector;
class Entity
{
public:
Entity() : X(0), Y(0) {}
Entity(int X, int Y) : X(X), Y(Y) {}
int X, Y;
};
struct {
Entity PlayerLocation;
vector<Entity> Entities;
} fb;
double distanceSquare(const Entity & p, const Entity & q) {
double delta_x = p.X - q.X;
double delta_y = p.Y - q.Y;
return (delta_x * delta_x + delta_y * delta_y);
}
Entity & GetNearestEntity()
{
return *std::min_element(fb.Entities.begin(), fb.Entities.end(),
[&fb](const Entity & a, const Entity & b) {
return distanceSquare(a, fb.PlayerLocation) <
distanceSquare(b, fb.PlayerLocation);
}
);
}
int main()
{
fb.Entities.push_back(Entity(1, 3));
fb.Entities.push_back(Entity(5, 1));
fb.Entities.push_back(Entity(-4, 2));
fb.PlayerLocation = Entity(6, 1);
Entity & nearest = GetNearestEntity();
cout << nearest.X << "/" << nearest.Y << endl;
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBzdGQ6OmNvdXQ7CnVzaW5nIHN0ZDo6ZW5kbDsKdXNpbmcgc3RkOjp2ZWN0b3I7CgoKY2xhc3MgRW50aXR5CnsKcHVibGljOgogICAgRW50aXR5KCkgOiBYKDApLCBZKDApIHt9CiAgICBFbnRpdHkoaW50IFgsIGludCBZKSA6IFgoWCksIFkoWSkge30KICAgIAogICAgaW50IFgsIFk7Cn07CiAgICAKCnN0cnVjdCB7CiAgICBFbnRpdHkgUGxheWVyTG9jYXRpb247CiAgICB2ZWN0b3I8RW50aXR5PiBFbnRpdGllczsKfSBmYjsKCgpkb3VibGUgZGlzdGFuY2VTcXVhcmUoY29uc3QgRW50aXR5ICYgcCwgY29uc3QgRW50aXR5ICYgcSkgewogICAgZG91YmxlIGRlbHRhX3ggPSBwLlggLSBxLlg7CiAgICBkb3VibGUgZGVsdGFfeSA9IHAuWSAtIHEuWTsKICAgIHJldHVybiAo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