#include "soccer.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
//#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define ff first
#define ss second
#define sp << " " <<
#define all(x) x.begin(),x.end()
#define big(x) ((int)(x.size()))
using namespace std;
const int MOD = 1e9+7, LIM = 1e6+1, inf = 2e9;
int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
vector<pii> maximal[N+1];
for (int j = 1;j<=N;j++) {
for (int i = 1;i<=N;) {
if (F[i-1][j-1] == 1) {
i++;
continue;
}
int cur = i;
while (cur < N && F[cur][j-1] == 0) cur++;
maximal[j].push_back({i,cur});
i = cur+1;
}
}
int dp[N+1][N+1][N+1][N+1];
memset(dp,0,sizeof dp);
int ans = 0;
for (int L = N;L>=1;L--) {
for (auto it : maximal[L]) {
int& dpp = dp[L][L][it.ff][it.ss];
dpp = max(dpp,it.ss-it.ff+1);
}
for (int R= L; R <= N;R++) {
for (int l = 1;l<=N;l++) {
for (int r = l;r <= N;r++) {
if (!dp[L][R][l][r]) continue;
ans = max(ans,dp[L][R][l][r]);
if (L>1) {
for (auto it : maximal[L-1]) {
int newl = max(l,it.ff),newr = min(r,it.ss);
if (newl > newr) continue;
int& dpp = dp[L-1][R][newl][newr];
dpp = max(dpp,dp[L][R][l][r]+newr-newl+1);
}
}
if (R < N) {
for (auto it : maximal[R+1]) {
int newl = max(l,it.ff),newr = min(r,it.ss);
if (newl > newr) continue;
int& dpp = dp[L][R+1][newl][newr];
dpp = max(dpp,dp[L][R][l][r]+newr-newl+1);
}
}
}
}
}
}
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... |