#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
vector<vector<vector<vector<int>>>> dp(2,vector<vector<vector<int>>>(N,vector<vector<int>>(N,vector<int>(N,0))));
int ans = 0;
for (int l = 0; l < N; l++){
for (int r = l; r < N; r++){
dp[0][N-1][l][r]=r-l+1;
for (int i = l; i <= r; i++){
if (F[N-1][i]==1){
dp[0][N-1][l][r]=0;
break;
}
}
dp[1][N-1][l][r]=dp[0][N-1][l][r];
ans=max(ans,dp[1][N-1][l][r]);
}
}
for (int i = N-2; i >= 0; i--){
for (int l = 0; l < N; l++){
for (int r = N-1; r >= l; r--){
dp[0][i][l][r]=r-l+1;
for (int j = l; j <= r; j++){
if (F[i][j]==1){
dp[0][i][l][r]=0;
break;
}
}
if (dp[0][i][l][r]==0) {
dp[1][i][l][r]=0;
continue;
}
int cur = 0;
int lel = l;
for (int j = l; j <= r; j++){
if (F[i+1][j]==0){
cur=max(cur,dp[0][i+1][lel][j]);
}
else {
lel=j+1;
}
}
dp[0][i][l][r]+=cur;
dp[1][i][l][r]=dp[0][i][l][r];
if (l>0){
dp[1][i][l][r]=max(dp[1][i][l][r],dp[1][i][l-1][r]);
}
if (r+1<N){
dp[1][i][l][r]=max(dp[1][i][l][r],dp[1][i][l][r+1]);
}
dp[1][i][l][r]=max(dp[1][i][l][r],r-l+1+dp[1][i+1][l][r]);
ans=max(ans,dp[1][i][l][r]);
}
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
33 ms |
13404 KB |
ok |
8 |
Execution timed out |
4635 ms |
1500512 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Incorrect |
0 ms |
344 KB |
wrong |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Incorrect |
0 ms |
344 KB |
wrong |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
1 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Incorrect |
0 ms |
344 KB |
wrong |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
1 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Incorrect |
0 ms |
344 KB |
wrong |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
33 ms |
13404 KB |
ok |
9 |
Execution timed out |
4635 ms |
1500512 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |