#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 30 + 7;
int a[N][N], pref[N][N], dp[N][N][N][N];
bool ok(int l, int x, int y) {
return pref[l][y] - pref[l][x - 1] == 0;
}
int biggest_stadium(int n, vector<vector<int>> f) {
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
a[i][j] = f[i - 1][j - 1];
pref[i][j] = pref[i][j - 1] + a[i][j];
}
}
for (int i = 1; i <= n; ++i) {
for (int l = 1; l <= n; ++l) {
for (int r = l; r <= n; ++r) {
if (ok(i, l, r)) dp[i][i][l][r] = r - l + 1;
}
}
}
for (int up = 1; up <= n; ++up) {
for (int down = up; down <= n; ++down) {
for (int l = 1; l <= n; ++l) {
for (int r = l; r <= n; ++r) {
for (int x = l; x <= r; ++x) {
for (int y = x; y <= r; ++y) {
if (ok(up - 1, x, y)) {
dp[up - 1][down][x][y] = max(dp[up - 1][down][x][y], dp[up][down][l][r] + y - x + 1);
}
if (ok(down + 1, x, y)) {
dp[up][down + 1][x][y] = max(dp[up][down + 1][x][y], dp[up][down][l][r] + y - x + 1);
}
}
}
}
}
}
}
int ans = 0;
for (int up = 1; up <= n; ++up) {
for (int down = up; down <= n; ++down) {
for (int l = 1; l <= n; ++l) {
for (int r = l; r <= n; ++r) {
ans = max(ans, dp[up][down][l][r]);
}
}
}
}
return ans;
}
# | 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... |