#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 31;
// dp[i][j][k][l] = biggest stadium that can fit in rows i..j,
// columns k..l currently active
int dp[MAXN][MAXN][MAXN][MAXN];
int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
int n = N;
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 ++)
dp[i][j][k][l] = -1e9;
for (int i = 0; i < n; i ++) {
for (int k = 0; k < n; k ++) {
for (int l = k; l < n; l ++) {
bool free = true;
for (int ii = k; ii <= l; ii ++)
if (F[i][ii])
free = false;
if (!free) continue;
dp[i][i][k][l] = l - k + 1;
}
}
}
for (int height = 2; height <= n; height ++) {
for (int i = 0; i < n - height + 1; i ++) {
int j = i + height - 1;
// add on top
for (int k = 0; k < n; k ++) {
for (int l = k; l < n; l ++) {
bool free = true;
for (int ii = k; ii <= l; ii ++)
if (F[i][ii])
free = false;
if (!free) continue;
int best = 0;
for (int kk = k; kk >= 0; kk --)
for (int ll = l; ll < n; ll ++)
best = max(best, dp[i + 1][j][kk][ll]);
// cout << i << " " << j << " " << k << " " << l << " " << best << " ";
dp[i][j][k][l] = max(dp[i][j][k][l], best + l - k + 1);
}
}
// add on bottom
for (int k = 0; k < n; k ++) {
for (int l = k; l < n; l ++) {
bool free = true;
for (int ii = k; ii <= l; ii ++)
if (F[j][ii])
free = false;
if (!free) continue;
int best = 0;
for (int kk = k; kk >= 0; kk --)
for (int ll = l; ll < n; ll ++)
best = max(best, dp[i][j - 1][kk][ll]);
// cout << i << " " << j << " " << k << " " << l << " " << best << " ";
dp[i][j][k][l] = max(dp[i][j][k][l], best + l - k + 1);
}
}
}
}
int best = 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 ++)
best = max(best, dp[i][j][k][l]);
return best;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
ok |
2 |
Correct |
1 ms |
2396 KB |
ok |
3 |
Correct |
1 ms |
2396 KB |
ok |
4 |
Correct |
1 ms |
2396 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Partially correct |
1 ms |
2396 KB |
partial |
7 |
Runtime error |
16 ms |
7888 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
ok |
2 |
Correct |
1 ms |
2396 KB |
ok |
3 |
Correct |
1 ms |
2396 KB |
ok |
4 |
Correct |
1 ms |
2396 KB |
ok |
5 |
Correct |
0 ms |
2396 KB |
ok |
6 |
Correct |
1 ms |
2396 KB |
ok |
7 |
Correct |
0 ms |
2396 KB |
ok |
8 |
Correct |
0 ms |
2392 KB |
ok |
9 |
Correct |
0 ms |
2396 KB |
ok |
10 |
Correct |
1 ms |
2396 KB |
ok |
11 |
Incorrect |
1 ms |
2396 KB |
wrong |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
ok |
2 |
Correct |
1 ms |
2396 KB |
ok |
3 |
Correct |
1 ms |
2396 KB |
ok |
4 |
Correct |
1 ms |
2396 KB |
ok |
5 |
Correct |
1 ms |
2396 KB |
ok |
6 |
Correct |
0 ms |
2396 KB |
ok |
7 |
Correct |
1 ms |
2396 KB |
ok |
8 |
Correct |
0 ms |
2396 KB |
ok |
9 |
Correct |
0 ms |
2392 KB |
ok |
10 |
Correct |
0 ms |
2396 KB |
ok |
11 |
Correct |
1 ms |
2396 KB |
ok |
12 |
Incorrect |
1 ms |
2396 KB |
wrong |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
ok |
2 |
Correct |
1 ms |
2396 KB |
ok |
3 |
Correct |
1 ms |
2396 KB |
ok |
4 |
Correct |
1 ms |
2396 KB |
ok |
5 |
Correct |
1 ms |
2396 KB |
ok |
6 |
Correct |
1 ms |
2396 KB |
ok |
7 |
Correct |
1 ms |
2396 KB |
ok |
8 |
Correct |
0 ms |
2396 KB |
ok |
9 |
Correct |
1 ms |
2396 KB |
ok |
10 |
Correct |
0 ms |
2396 KB |
ok |
11 |
Correct |
0 ms |
2392 KB |
ok |
12 |
Correct |
0 ms |
2396 KB |
ok |
13 |
Correct |
1 ms |
2396 KB |
ok |
14 |
Incorrect |
1 ms |
2396 KB |
wrong |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
ok |
2 |
Correct |
1 ms |
2396 KB |
ok |
3 |
Correct |
1 ms |
2396 KB |
ok |
4 |
Correct |
1 ms |
2396 KB |
ok |
5 |
Correct |
1 ms |
2396 KB |
ok |
6 |
Correct |
1 ms |
2396 KB |
ok |
7 |
Correct |
1 ms |
2396 KB |
ok |
8 |
Correct |
0 ms |
2396 KB |
ok |
9 |
Correct |
1 ms |
2396 KB |
ok |
10 |
Correct |
0 ms |
2396 KB |
ok |
11 |
Correct |
0 ms |
2392 KB |
ok |
12 |
Correct |
0 ms |
2396 KB |
ok |
13 |
Correct |
1 ms |
2396 KB |
ok |
14 |
Incorrect |
1 ms |
2396 KB |
wrong |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
ok |
2 |
Correct |
1 ms |
2396 KB |
ok |
3 |
Correct |
1 ms |
2396 KB |
ok |
4 |
Correct |
1 ms |
2396 KB |
ok |
5 |
Correct |
1 ms |
2396 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Partially correct |
1 ms |
2396 KB |
partial |
8 |
Runtime error |
16 ms |
7888 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |