This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "soccer.h"
using namespace std;
#define ll long long
#define ff first
#define ss second
#define ln "\n"
ll n;
int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
n=N;
vector<vector<ll>> gr(n+1, vector<ll>(n+1));
vector<vector<pair<ll, ll>>> A(N+2, vector<pair<ll, ll>>(N+2, {0, n+1}));
for (ll i=1; i<=n; i++){
for (ll j=1; j<=n; j++){
gr[i][j]=F[i-1][j-1];
A[i][j].ff=A[i][j-1].ff;
if (gr[i][j]){
A[i][j].ff=j;
}
}
}
for (ll i=1; i<=n; i++){
for (ll j=n; j>=1; j--){
A[i][j].ss=A[i][j+1].ss;
if (gr[i][j]){
A[i][j].ss=j;
}
}
}
// for (ll i=1; i<=n; i++){
// for (ll j=1; j<=n; j++){
// cout << A[i][j].ff << "|" << A[i][j].ss << " ";
// }
// cout << ln;
// }
// cout << ln;
ll res=0;
for (ll i=1; i<=n; i++){
for (ll j=1; j<=n; j++){
// vector<ll> debug;
ll l=A[i][j].ff, r=A[i][j].ss;
ll ans=-(r-l-1);
ll ch=i;
while (ch>0 and l<j and r>j and l<r){
ans+=r-l-1;
ch--;
l = max(l, A[ch][j].ff);
r = min(r, A[ch][j].ss);
}
l=A[i][j].ff; r=A[i][j].ss;
// debug.push_back(ch);
ch = i;
while (ch<=n and l<j and r>j and l<r){
ans+=r-l-1;
ch++;
l = max(l, A[ch][j].ff);
r = min(r, A[ch][j].ss);
}
// debug.push_back(ch);
// cout << i << " " << j << " -> " << ans << ": ";
// for (auto cch:debug){
// cout << cch << " ";
// }
// cout << ln;
if (res<ans){
res=ans;
}
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |