#include "soccer.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using namespace std;
#define F first
#define S second
#define sz size()
#define all(x) (x).begin(), (x).end()
const int N = 32;
ll n;
vector<vector<int> > a;
ll dp[N][N][N][2];
ll pre[N][N];
int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
n = N, a = F;
for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) pre[i][j] = pre[i][j-1]+a[i-1][j-1];
//for(int i = 1; i <= n; i++) {for(int j = 1; j <= n;j++) cout << pre[i][j] << " "; cout << endl;}
// base case
for(int r = 1; r <= n; r++)
for(int i = 1; i <= n; i++) for(int j = i; j <= n ;j++)
{
ll cnt = pre[r][j]-pre[r][i-1];
if(cnt>0) continue;
dp[r][i][j][0] = j-i+1;
// cout << dp[1][i][j][0] << " ";
}
for(int r = 2; r<= n; r++)
for(int i2 = 1; i2 <= n; i2++)
{
for(int j2 = i2; j2 <= n; j2++)
{
ll cnt = pre[r-1][j2]-pre[r-1][i2-1];
if(cnt>0) continue;
for(int i = 1; i <= n; i++)
{
for(int j =i ; j <= n; j++)
{
cnt = pre[r][j]-pre[r][i-1];
if(cnt>0) continue;
// if(i==2&&j==5&&r==2&&i2==1&&j2==5) cout << dp[r-1][i2][j2][0] << endl;
if(i2>=i&&j2<=j) // prev is sub from me
{dp[r][i][j][0] = max(dp[r][i][j][0],dp[r-1][i2][j2][0]+j-i+1);
dp[r][i][j][1] = max(dp[r][i][j][1],dp[r-1][i2][j2][0]+j-i+1);
}
else if(i2<=i&&j2>=j)
dp[r][i][j][1] = max({dp[r][i][j][1],dp[r-1][i2][j2][0]+j-i+1,dp[r-1][i2][j2][1]+j-i+1});
}
}
}
}
// cout << dp[2][3][4][1] << endl;
ll best = 0;
for(int r = 1; r <= n; r++)
for(int i = 1; i <= n; i++)
{
for(int j = i; j <= n; j++)
//if(dp[r][i][j][1]==21) cout<<r << i << " " << j << endl;
best = max({best,dp[r][i][j][0],dp[r][i][j][1]});
}
return best;
}
/*
5
0 0 0 0 0
1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 1 0 0
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
# |
Verdict |
Execution time |
Memory |
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 |
Runtime error |
1 ms |
1628 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Partially correct |
1 ms |
348 KB |
partial |
4 |
Partially correct |
0 ms |
348 KB |
partial |
5 |
Incorrect |
0 ms |
512 KB |
wrong |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Partially correct |
1 ms |
348 KB |
partial |
5 |
Partially correct |
0 ms |
348 KB |
partial |
6 |
Incorrect |
0 ms |
512 KB |
wrong |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
Partially correct |
1 ms |
348 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Incorrect |
0 ms |
512 KB |
wrong |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
Partially correct |
1 ms |
348 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Incorrect |
0 ms |
512 KB |
wrong |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
348 KB |
ok |
8 |
Runtime error |
1 ms |
1628 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |