Geek Week: Local is a week-long hackathon of creating hacks, solving problems, and building profiles both big and small. Choose between daily and week-long challenges that vary in difficulty. The more challenges you conquer, the more points you’ll earn and make your position on the leaderboard.
include <bits/stdc++.h>
using namespace std;
class FloodFill { public: vector getCell(vector , vector , long long);
};
const int inf = (int) 5e8;
vector FloodFill::getCell(vector X, vector Y, long long A) {
int n = (int) X.size();
auto Count = [&](int rad, int max_x, int max_y) -> long long {
vector xa(n);
vector ya(n);
vector xb(n);
vector yb(n);
for (int i = 0; i < n; i++) {
xa[i] = X[i] - rad;
ya[i] = Y[i] - rad;
xb[i] = X[i] + rad + 1;
yb[i] = Y[i] + rad + 1;
}
vector xs;
vector ys;
for (int i = 0; i < n; i++) {
xs.push_back(xa[i]);
ys.push_back(ya[i]);
xs.push_back(xb[i]);
ys.push_back(yb[i]);
}
xs.push_back(max_x);
xs.push_back(max_x - 1);
ys.push_back(max_y);
sort(xs.begin(), xs.end());
xs.resize(unique(xs.begin(), xs.end()) - xs.begin());
sort(ys.begin(), ys.end());
ys.resize(unique(ys.begin(), ys.end()) - ys.begin());
long long ret = 0;
for (int i = 0; i < (int) xs.size() - 1; i++) {
for (int j = 0; j < (int) ys.size() - 1; j++) {
int x1 = xs[i];
int y1 = ys[j];
int x2 = xs[i + 1];
int y2 = ys[j + 1];
if (x2 > max_x || (x2 == max_x && y2 > max_y)) {
continue;
}
bool inside = false;
for (int k = 0; k < n; k++) {
if (x1 >= xa[k] && y1 >= ya[k] && xb[k] >= x2 && yb[k] >= y2) {
inside = true;
break;
}