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<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18+7;
struct seg
{
int cnt[3200010];
int lm[3200010],rm[3200010],mx[3200010],sz[3200010];
inline void calc(int n,int s,int e)
{
if(cnt[n]>0)
{
lm[n]=rm[n]=mx[n]=0;
return;
}
if(s==e)
{
lm[n]=rm[n]=mx[n]=1;
return;
}
lm[n]=lm[n*2]==sz[n*2]?sz[n*2]+lm[n*2+1]:lm[n*2];
rm[n]=rm[n*2+1]==sz[n*2+1]?sz[n*2+1]+rm[n*2]:rm[n*2+1];
mx[n]=max({mx[n*2],mx[n*2+1],rm[n*2]+lm[n*2+1]});
return;
}
inline void init(int n,int s,int e)
{
cnt[n]=0;
lm[n]=rm[n]=mx[n]=sz[n]=e-s+1;
if(s==e)
return;
int m=(s+e)/2;
init(n*2,s,m);
init(n*2+1,m+1,e);
return;
}
void si(int n,int s,int e,int S,int E,int p)
{
if(s>E||S>e)
return;
if(S<=s&&e<=E)
{
cnt[n]+=p;
calc(n,s,e);
return;
}
int m=(s+e)/2;
si(n*2,s,m,S,E,p);
si(n*2+1,m+1,e,S,E,p);
calc(n,s,e);
return;
}
int sq()
{
return mx[1];
}
}st;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,m,p;
cin>>n>>m;
cin>>p;
cin>>p;
vector<vector<pi> >qv1(n+1),qv2(n+1);
st.init(1,1,m);
for(int i=0;i<p;i++)
{
int x1,x2,y1,y2,c;
cin>>x1>>y1>>x2>>y2>>c;
qv1[x1].eb(y1,y2);
qv2[x2].eb(y1,y2);
}
int l=1;
int ans=0;
for(int r=1;r<=n;r++)
{
for(pi&t:qv1[r])
st.si(1,1,m,t.fi,t.se,1);
while(st.sq()<r-l+1)
{
ans=max(ans,min(r-l+1,st.sq()));
for(pi&t:qv2[l])
st.si(1,1,m,t.fi,t.se,-1);
l++;
}
ans=max(ans,r-l+1);
}
cout<<ans<<endl;
return 0;
}
# | 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... |
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |