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>
using namespace std;
typedef long long int lld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)
int table[2000][2000];
int n;
int pref[50][50];
vector<pair<int,int> >inter[1000][1000];
int tot[1000];
vector<lld> ans[1000][1000];
int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
n=N;
rep(i,0,n){
rep(j,0,n){
table[i][j]=F[i][j];
}
}
rep(i,0,n){
rep(i,0,n)tot[i]=0;
rep(j,i,n){
rep(k,0,n)tot[k]+=table[j][k];
int lst=-1;
rep(k,0,n+1){
if(k==n || tot[k]>0){
if(k-lst>=2){
inter[i][j].push_back({k-1,lst+1});
}
lst=k;
}
}
ans[i][j].resize(inter[i][j].size(),0);
}
}
for(int diff=n-1;diff>0;diff--){
for(int i=0;i+diff<n;i++){
int j=i+diff;
rep(k,0,(int)inter[i][j].size()){
int pos1=lower_bound(inter[i][j-1].begin(),inter[i][j-1].end(),pair<int,int>(inter[i][j][k].first,-1e9))-inter[i][j-1].begin();
ans[i][j-1][pos1]=max(ans[i][j-1][pos1],ans[i][j][k]+inter[i][j][k].first-inter[i][j][k].second+1);
//cout<<i<<" "<<j<<" "<<inter[i][j][k].first<<" "<<inter[i][j][k].second<<" "<<inter[i][j-1][pos1].first<<" "<<inter[i][j-1][pos1].second<<endl;
pos1=lower_bound(inter[i+1][j].begin(),inter[i+1][j].end(),pair<int,int>(inter[i][j][k].first,-1e9))-inter[i+1][j].begin();
ans[i+1][j][pos1]=max(ans[i+1][j][pos1],ans[i][j][k]+inter[i][j][k].first-inter[i][j][k].second+1);
}
}
}
lld res=0;
rep(i,0,n){
rep(k,0,(int)(inter[i][i].size())){
res=max(res,ans[i][i][k]+inter[i][i][k].first-inter[i][i][k].second+1);
}
}
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... |