This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "soccer.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int biggest_stadium(int n, vector<vector<int>> F){
vector<vector<vector<vector<int>>>> dp(n,
vector<vector<vector<int>>>(n, vector<vector<int>>(n, vector<int>(n, 0))));
auto mx = dp;
for(int i = 0; i < n; i++){
for(int l = 0; l < n; l++) for(int r = l; r < n; r++){
if(F[i][r]) break;
dp[i][i][l][r] = r-l+1;
mx[i][i][l][r] = r-l+1;
}
for(int l = 0; l < n; l++) for(int r = n-1; r >= l; r--){
if(l) mx[i][i][l][r] = max(mx[i][i][l][r], mx[i][i][l-1][r]);
if(r+1 < n) mx[i][i][l][r] = max(mx[i][i][l][r], mx[i][i][l][r+1]);
}
}
for(int a = n-1; a >= 0; a--) for(int b = a+1; b < n; b++) for(int l = 0; l < n; l++) for(int r = n-1; r >= l; r--){
if(dp[a][a][l][r] != 0 && mx[a+1][b][l][r] != 0) dp[a][b][l][r] = max(dp[a][b][l][r], mx[a+1][b][l][r]+dp[a][a][l][r]);
if(dp[b][b][l][r] != 0 && mx[a][b-1][l][r] != 0) dp[a][b][l][r] = max(dp[a][b][l][r], mx[a][b-1][l][r]+dp[b][b][l][r]);
mx[a][b][l][r] = max(mx[a][b][l][r], dp[a][b][l][r]);
if(l) mx[a][b][l][r] = max(mx[a][b][l][r], mx[a][b][l-1][r]);
if(r+1 < n) mx[a][b][l][r] = max(mx[a][b][l][r], mx[a][b][l][r+1]);
}
int ans = 0;
for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) for(int k = 0; k < n; k++) for(int l = 0; l < n; l++){
ans = max(ans, dp[i][j][k][l]);
}
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... |