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>
using namespace std;
int haha[700][700];
int l[700][700];
int r[700][700];
int n;
int calc(int a) {
vector<pair<int,int>> wut(0);
for(int i = 0; i < n; i++) {
wut.push_back({l[i][a],r[i][a]});
}
int dp[n][n];
int ans = 0;
pair<int,int> yay[n][n];
for(int i = 0; i < n; i++) {
if(wut[i].first != -1) {
dp[i][i] = wut[i].first+wut[i].second+1;
ans = max(ans,dp[i][i]);
}
else {
dp[i][i] = 0;
}
yay[i][i] = wut[i];
}
for(int i = 1; i < n; i++) {
for(int j = 0; j < n-i; j++) {
int k = i;
i = j+i;
swap(i,j);
yay[i][j] = {min(yay[i][j-1].first,yay[j][j].first),min(yay[i][j-1].second,yay[j][j].second)};
if(yay[i][j].first == -1) {
dp[i][j] = 0;
}
else {
dp[i][j] = dp[i][j-1]+yay[i][j].first+yay[i][j].second+1;
dp[i][j] = max(dp[i][j],dp[i+1][j]+yay[i][j].first+yay[i][j].second+1);
ans = max(ans,dp[i][j]);
}
swap(i,j);
i = k;
}
}
return ans;
}
int biggest_stadium(int N, std::vector<std::vector<int>> f)
{
n = N;
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
haha[i][j] = f[i][j];
}
}
for(int i = 0; i < n; i++) {
if(haha[i][0]) {
l[i][0] = -1;
}
else {
l[i][0] = 0;
}
for(int j = 1; j < n; j++) {
if(haha[i][j]) {
l[i][j] = -1;
}
else {
l[i][j] = l[i][j-1]+1;
}
}
if(haha[i][n-1]) {
r[i][n-1] = -1;
}
else {
r[i][n-1] = 0;
}
for(int j = n-2; j >= 0; j--) {
if(haha[i][j]) {
r[i][j] = -1;
}
else {
r[i][j] = r[i][j+1]+1;
}
}
}
int ans = 0;
for(int i = 0; i < n; i++) {
ans = max(ans,calc(i));
}
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... |