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 "soccer.h"
#include <bits/stdc++.h>
int n,next[2010][2010],ans;
std::map<std::pair<std::pair<int,int>,std::pair<int,int>>,int>val;
std::priority_queue<std::pair<int,std::pair<std::pair<int,int>,std::pair<int,int>>>>q;
void adauga(int up,int down,int l,int r,int valac)
{
std::pair<std::pair<int,int>,std::pair<int,int>>cod={{up,down},{l,r}};
if(val.find(cod)==val.end())
{
q.push({up-down,cod});
val[cod]=valac;
}
else
if(valac>val[cod])
val[cod]=valac;
if(valac>ans)
ans=valac;
}
int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
n=N;
for(int i=0;i<n;++i)
{
next[i][n]=n-1;
for(int j=n-1;j>=0;--j)
{
if(F[i][j]==1)
next[i][j]=j-1;
else
next[i][j]=next[i][j+1];
}
}
for(int i=0;i<n;++i)
{
int poz=0;
while(poz!=n)
{
if(next[i][poz]<poz)
++poz;
else
{
adauga(i,i,poz,next[i][poz],next[i][poz]-poz+1);
poz=next[i][poz]+1;
}
}
}
while(!q.empty())
{
std::pair<std::pair<int,int>,std::pair<int,int>>cod=q.top().second;
q.pop();
int up=cod.first.first;
int down=cod.first.second;
int l=cod.second.first;
int r=cod.second.second;
if(up)
{
int poz=l;
while(poz<=r)
{
if(next[up-1][poz]>=poz)
{
adauga(up-1,down,poz,std::min(next[up-1][poz],r),val[cod]+std::min(next[up-1][poz],r)-poz+1);
poz=next[up-1][poz]+1;
}
else
++poz;
}
}
if(down+1!=n)
{
int poz=l;
while(poz<=r)
{
if(next[down+1][poz]>=poz)
{
adauga(up,down+1,poz,std::min(next[down+1][poz],r),val[cod]+std::min(next[down+1][poz],r)-poz+1);
poz=next[down+1][poz]+1;
}
else
++poz;
}
}
}
return ans;
}
# | 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... |