Submission #533013

#TimeUsernameProblemLanguageResultExecution timeMemory
533013prvocisloPyramid Base (IOI08_pyramid_base)C++17
65 / 100
1312 ms137176 KiB
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <vector> typedef long long ll; using namespace std; const int maxn = 1 << 20; struct node { int mini; int pf, sf, mx, l, r; int add; } st[maxn << 1]; void merge(const node& l, const node& r, node& n) { n.mini = min(l.mini, r.mini); if (n.mini == l.mini) n.pf = l.pf + ((l.pf == l.r - l.l + 1 && n.mini == r.mini) ? r.pf : 0); else n.pf = 0; if (n.mini == r.mini) n.sf = r.sf + ((r.sf == r.r - r.l + 1 && n.mini == l.mini) ? l.sf : 0); else n.sf = 0; n.mx = max(n.pf, n.sf); if (n.mini == l.mini) n.mx = max(n.mx, l.mx); if (n.mini == r.mini) n.mx = max(n.mx, r.mx); if (n.mini == l.mini && n.mini == r.mini) n.mx = max(n.mx, l.sf + r.pf); n.mini += n.add; } void update(int li, int ri, int x, int vr = 1) { if (ri < st[vr].l || st[vr].r < li) return; if (li <= st[vr].l && st[vr].r <= ri) { st[vr].mini += x; st[vr].add += x; return; } update(li, ri, x, (vr << 1)); update(li, ri, x, (vr << 1) | 1); merge(st[(vr << 1)], st[(vr << 1) | 1], st[vr]); } struct udalost { int x1, x2; }; int main() { ios::sync_with_stdio(false); cin.tie(0); for (int i = maxn; i < maxn * 2; i++) { st[i].l = i - maxn; st[i].r = i - maxn; st[i].pf = st[i].sf = st[i].mx = 1; } for (int i = maxn - 1; i > 0; i--) { st[i].l = st[(i << 1)].l; st[i].r = st[(i << 1) | 1].r; merge(st[(i << 1)], st[(i << 1) | 1], st[i]); } int X, Y, B, p; cin >> X >> Y >> B >> p; update(0, 0, 1); update(X + 1, maxn, 1); vector<vector<udalost> > b(Y + 2), e(Y + 2); for (int i = 0; i < p; i++) { int x1, y1, x2, y2, c; cin >> x1 >> y1 >> x2 >> y2 >> c; b[y1].push_back({ x1, x2 }); e[y2].push_back({ x1, x2 }); } int x1 = 0, x2 = 0; // x2 je prve zle int ans = 0; while (x2 <= Y) { int len = st[1].mini == 0 ? st[1].mx : 0; if (len < x2 - x1 + 1 || x1 == 0) { for (udalost u : e[x1]) update(u.x1, u.x2, -1); x1++; } else { x2++; for (udalost u : b[x2]) update(u.x1, u.x2, 1); } ans = max(ans, x2 - x1); } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...