Submission #533013

# Submission time Handle Problem Language Result Execution time Memory
533013 2022-03-04T11:12:34 Z prvocislo Pyramid Base (IOI08_pyramid_base) C++17
65 / 100
1312 ms 137176 KB
#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 time Memory Grader output
1 Correct 34 ms 57748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 57640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 57756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 58180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 62452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 104736 KB Output is correct
2 Correct 75 ms 104704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 104700 KB Output is correct
2 Correct 60 ms 104696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 58488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 63712 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 115 ms 106448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 128 ms 106984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 133 ms 107384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 663 ms 121900 KB Output is correct
2 Correct 443 ms 71908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 846 ms 129748 KB Output is correct
2 Correct 872 ms 126576 KB Output is correct
3 Correct 547 ms 121916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1062 ms 137176 KB Output is correct
2 Correct 1312 ms 134020 KB Output is correct
3 Correct 1298 ms 133940 KB Output is correct
4 Correct 1143 ms 133460 KB Output is correct
5 Correct 887 ms 127288 KB Output is correct