#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#define pb push_back
#define F first
#define pii pair<int,int>
#define all(a) a.begin(),a.end()
#define S second
#define sz(a) (int)a.size()
#define rep(i , a , b) for(int i = (a) ; i <= (b) ; i++)
#define per(i , a , b) for(int i = (a) ; i >= (b) ; i--)
#define ld double
#define ll long long
using namespace std ;
const int maxn = 30 + 10 ,s = 1000 , inf = 1e9 , mod = 998244353;
int d[maxn][maxn][maxn][maxn] , u[maxn][maxn][maxn][maxn];
int pr[maxn][maxn] ;
int biggest_stadium(int n, std::vector<std::vector<int>> F){
rep(i , 1 , n){
rep(j , 1, n){
pr[i][j] = pr[i][j-1] + F[i-1][j-1] ;
}
}
rep(l1,0,n)rep(r1,0,n)rep(l,0,n)rep(r,0,n)d[l1][r1][l][r] = u[l1][r1][l][r] = -inf ;
int ans =0 ;
rep(i ,1, n){
rep(l , 1 , n){
rep(r,l,n){
if(pr[i][r]-pr[i][l-1] == 0){
u[i][i][l][r] = r-l+1;
d[i][i][l][r] = r-l+1;
ans = max(ans , r-l+1) ;
}
}
}
}
rep(len , 2 , n){
for(int l1 = 1 , r1 = len ; r1 <= n ; r1++,l1++){
rep(l, 1, n){
rep(r,l ,n){
if(pr[l1][r]-pr[l1][l-1]==0){
int s= r-l+1 ;
rep(l2 , 1 , l){
rep(r2 , r , n){
u[l1][r1][l][r] = max({u[l1][r1][l][r] , u[l1+1][r1][l2][r2]+s , d[l1+1][r1][l2][r2]+s}) ;
}
}
}
if(pr[r1][r]-pr[r1][l-1] == 0){
int s = r-l+1 ;
rep(l2 , 1 , l){
rep(r2 , r , n){
d[l1][r1][l][r] = max({d[l1][r1][l][r] , d[l1][r1-1][l2][r2]+s , u[l1][r1-1][l2][r2]+s}) ;
}
}
}
ans = max({ans , d[l1][r1][l][r] , u[l1][r1][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... |