#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 |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
10232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
88528 KB |
Output is correct |
2 |
Correct |
78 ms |
88440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
78 ms |
88680 KB |
Output is correct |
2 |
Correct |
74 ms |
88516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
1912 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
41 ms |
11512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
135 ms |
90232 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
151 ms |
90744 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
178 ms |
91288 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
805 ms |
105592 KB |
Output is correct |
2 |
Correct |
373 ms |
63992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1055 ms |
113560 KB |
Output is correct |
2 |
Correct |
989 ms |
109648 KB |
Output is correct |
3 |
Correct |
707 ms |
60364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1341 ms |
120964 KB |
Output is correct |
2 |
Correct |
1503 ms |
118464 KB |
Output is correct |
3 |
Correct |
1465 ms |
118308 KB |
Output is correct |
4 |
Correct |
1282 ms |
116356 KB |
Output is correct |
5 |
Correct |
947 ms |
110976 KB |
Output is correct |