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