#include <bits/stdc++.h>
#include "soccer.h"
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
ll inf = 1e18;
int n;
bool all_good(vector<vector<int>> f, int chi, int chj) {
bool ok = 1;
for (int vi = chi; vi <= chi; vi++) {
for (int vj = chj; vj <= chj; vj++) {
for (int ui = 0; ui < n; ui++) {
for (int uj = 0; uj < n; uj++) {
if (!(f[vi][vj] == 0 && f[ui][uj] == 0))
continue;
int mini = min(vi, ui);
int maxi = max(vi, ui);
int minj = min(vj, uj);
int maxj = max(vj, uj);
bool fii = 1, fij = 1;
for (int i = mini; i <= maxi; i++) {
if (f[i][vj] == 1)
fii = 0;
if (f[i][uj] == 1)
fij = 0;
}
for (int j = minj; j <= maxj; j++) {
if (f[ui][j] == 1)
fii = 0;
if (f[vi][j] == 1) {
fij = 0;
}
}
if (fii == 0 && fij == 0) {
ok = 0;
}
}
}
}
}
return ok;
}
vector<vector<int>> constr(set<pair<int, int>> st) {
vector<vector<int>> vec(n, vector<int>(n, 1));
for (auto [i, j] : st) {
vec[i][j] = 0;
}
return vec;
}
int biggest_stadium(int N, vector<vector<int>> f) {
int res = 0;
n = N;
vector<set<pair<int, int>>> st, newst;
set<set<pair<int, int>>> newSET;
vector<pair<int, int>> emp;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (f[i][j] == 0) {
set<pair<int,int>> setik = {{i, j}};
emp.push_back({i,j});
st.push_back(setik);
}
}
}
while (!st.empty()) {
res++;
newst.clear();
newSET.clear();
for (auto setik : st) {
for (auto [ci, cj] : emp) {
if (setik.find({ci, cj}) != setik.end()) {
continue;
}
setik.insert({ci, cj});
auto vec = constr(setik);
if (all_good(vec, ci, cj)) {
newst.push_back(setik);
}
setik.erase({ci, cj});
}
}
for (auto el : newst) {
newSET.insert(el);
}
st.clear();
int sz = newSET.size();
for (auto el : newSET) {
int rn = rnd() % sz;
if (rn < 100)
st.push_back(el);
}
}
return res;
}
/*
signed main() {
int N;
cin >> N;
vector<vector<int>> f(N, vector<int>(N));
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
cin >> f[i][j];
}
}
cout << biggest_stadium(N, f) << endl;
}
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |