#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define f first
#define s second
const int mxP = 4e5;
const int mxN = 1e6;
int n,m;
int segtree[4*mxN+1];
int laz[4*mxN+1];
int curr;
void build(int l = 0, int r = n-1, int idx = 0){
if (r+1<curr){
segtree[idx] = m+1;
laz[idx] = m+1;
return;
}
segtree[idx] = 0;
laz[idx] = 0;
if (l == r) return;
int m = (l+r)/2;
build(l,m,2*idx+1);
build(m+1,r,2*idx+2);
}
void upd(int tl, int tr, int v, int l = 0, int r = n-1, int idx = 0){
if (l > tr || r < tl || r+1<curr) return;
if (l >= tl && r <= tr){
laz[idx] = v;
return;
}
laz[2*idx+1] = laz[idx];
laz[2*idx+2] = laz[idx];
laz[idx] = 0;
int m = (l+r)/2;
upd(tl,tr,v,l,m,2*idx+1);
upd(tl,tr,v,m+1,r,2*idx+2);
segtree[idx] = min(max(segtree[2*idx+1],laz[2*idx+1]),max(segtree[2*idx+2],laz[2*idx+2]));
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int b,p;
cin >> m >> n >> b >> p;
int r[p];
pii y[p];
vector<pii> vals(p);
int x1,y1,x2,y2,c1;
for (int i =0; i < p; i++){
cin >> x1 >> y1 >> x2 >> y2 >> c1;
x1 -= 1;
y1 -= 1;
x2 -= 1;
y2 -= 1;
r[i] = x2;
y[i] = {y1,y2};
vals[i] = {x1,i};
}
if (b > 0){
while (true) continue;
return 0;
}
sort(vals.begin(),vals.end());
int start = 0;
int end = min(n,m)+1;
bool w;
int best;
while (end - start > 1){
curr = (start+end)/2;
build();
w = false;
// cout << curr << ": ";
for (int i = 0; i < p; i++){
// cout << vals[i].s << " - " << vals[i].f << " " << r[vals[i].s] << " " << y[vals[i].s].f << ',' << y[vals[i].s].s << " ";
best = max(laz[0],segtree[0]);
if (vals[i].f-best >= curr){
w = true;
break;
}
upd(y[vals[i].s].f,min(n-1,y[vals[i].s].s+curr-1),r[vals[i].s]+1);
}
//cout << '\n';
best = max(laz[0],segtree[0]);
if (m-best >= curr) w = true;
if (w) start = curr;
else end = curr;
}
cout << start << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
6492 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
19036 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
18788 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5031 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5025 ms |
600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5049 ms |
856 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5041 ms |
860 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5052 ms |
860 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
314 ms |
22868 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
428 ms |
24760 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
608 ms |
26708 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |