#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
#define pf push_front
#define pb push_back
#define ll long long
#define vi vector<int>
#define sz(a) (int)a.size()
#define lb lower_bound
#define ub upper_bound
#define all(a) begin(a),end(a)
const int mxN = 2010;
int n;
vector<int> col[mxN];
int solve(vector<vi> &a){
int ans = 0;
for(int i = 0; i < n; i++)
col[i].clear(), col[i].pb(-1);
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
if(a[i][j]) col[j].pb(i);
for(int i = 0; i < n; i++)
col[i].pb(n),sort(all(col[i]));
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(a[i][j]) continue;
for(int k = i; k < n; k++){
if(a[k][j]) break;
int mxJ = j;
for (int l = j; l < n; l++){
int nx_forest = *lb(all(col[l]),i);
if(nx_forest<=k) break; mxJ = l;
}
for(int l = j; l <= mxJ; l++){
int tot = 0, UP = i, DOWN = k;
if(l!=j){
while(UP>0 and !a[UP-1][l]) UP--;
while(DOWN<n-1 and !a[DOWN+1][l]) DOWN++;
}
tot+=DOWN-UP+1;
int up2 = UP, down2 = DOWN;
for(int m = l-1; m >= j; m--){
int forestUp = *(prev(lb(all(col[m]),i)));
int forestDown = *ub(all(col[m]),k);
int up = max(UP, forestUp+1);
int down = min(DOWN, forestDown-1);
tot+=down-up+1;
if(m==j) UP=i,DOWN=k;
else UP = up, DOWN = down;
}
UP = up2, DOWN = down2;
for(int m = l+1; m <= mxJ; m++){
int forestUp = *(prev(lb(all(col[m]),i)));
int forestDown = *ub(all(col[m]),k);
int up = max(UP, forestUp+1);
int down = min(DOWN, forestDown-1);
tot+=down-up+1;
if(m==j) UP=i,DOWN=k;
else UP = up, DOWN = down;
}
ans = max(ans, tot);
}
}
}
}
return ans;
}
int biggest_stadium(int N, vector<vi> a)
{
n = N; int ans = solve(a);
for(int i = 0; i < n; i++)
for(int j = 0; j < n/2; j++)
swap(a[i][j],a[i][n-j-1]);
ans = max(ans, solve(a));
return ans;
}
Compilation message
soccer.cpp: In function 'int solve(std::vector<std::vector<int> >&)':
soccer.cpp:36:6: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
36 | if(nx_forest<=k) break; mxJ = l;
| ^~
soccer.cpp:36:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
36 | if(nx_forest<=k) break; mxJ = l;
| ^~~
# |
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 |
1 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
344 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Execution timed out |
4526 ms |
348 KB |
Time limit exceeded |
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 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
348 KB |
ok |
6 |
Correct |
1 ms |
348 KB |
ok |
7 |
Incorrect |
0 ms |
348 KB |
wrong |
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 |
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 |
1 ms |
348 KB |
ok |
8 |
Incorrect |
0 ms |
348 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 |
1 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
1 ms |
348 KB |
ok |
9 |
Correct |
1 ms |
348 KB |
ok |
10 |
Incorrect |
0 ms |
348 KB |
wrong |
11 |
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 |
1 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
1 ms |
348 KB |
ok |
9 |
Correct |
1 ms |
348 KB |
ok |
10 |
Incorrect |
0 ms |
348 KB |
wrong |
11 |
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 |
1 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
344 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Execution timed out |
4526 ms |
348 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |