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 <bits/stdc++.h>
#include "soccer.h"
using namespace std;
#define pb push_back
#define st first
#define nd second
typedef long long ll;
typedef long double ld;
const ll I = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;
const int II = 2 * 1000 * 1000 * 1000;
const ll M = 1000LL * 1000LL * 1000LL + 7LL;
const int N = 507;
int tab[N][N];
int dp[2][2][N][N], dpm[2][2][N][N];
int biggest_stadium(int _N, vector<vector<int>> _F)
{
int n = _N;
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n; ++j)
tab[i][j] = _F[i - 1][j - 1];
int r = 0, ans = 0;
for(int l = 1; l <= n; ++l)
{
int pr = r ^ 1;
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n; ++j)
{dp[r][0][i][j] = 0; dp[r][1][i][j] = 0;}
for(int i = 1; i <= n; ++i)
for(int j = i; j <= n && tab[j][l] == 0; ++j)
{
dp[r][0][i][j] = dp[pr][0][i][j] + j - i + 1;
dp[r][1][i][j] = max(dp[pr][0][i][j], dp[pr][1][i][j]) + j - i + 1;
ans = max(ans, dp[r][1][i][j]);
}
for(int i = n; i >= 1; --i)
for(int j = i + 1; j <= n; ++j)
dp[r][0][i][j] = max(dp[r][0][i][j], max(dp[r][0][i + 1][j], dp[r][0][i][j - 1]));
for(int i = 1; i <= n; ++i)
for(int j = n; j > i; --j)
dp[r][1][i][j] = max(dp[r][1][i][j], max(dp[r][1][i - 1][j], dp[r][0][i][j + 1]));
r ^= 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... |