Coder Social home page Coder Social logo

Comments (1)

pharshithachowdary avatar pharshithachowdary commented on June 27, 2024

#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;
}

from geekweek-local.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.