Submission #520879

# Submission time Handle Problem Language Result Execution time Memory
520879 2022-01-31T10:57:44 Z pokmui9909 Pyramid Base (IOI08_pyramid_base) C++17
0 / 100
1095 ms 135844 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int S = (1 << 20);
struct Node{
    int l, r, mn, len, pfx, sfx, d;
    Node operator+(const Node &k)const{
        Node ret = {l, k.r, min(mn, k.mn), len + k.len, pfx, k.sfx, 0LL};
        if(mn == ret.mn) ret.d = d;
        if(k.mn == ret.mn) ret.d = k.d;
        if(pfx == len && l == k.l) ret.pfx = len + k.pfx;
        if(k.sfx == k.len && r == k.r) ret.sfx = k.len + sfx;
        if(r == k.l && r == ret.mn) ret.d = max(ret.d, sfx + k.pfx);
        return ret;
    }
};
struct SegTree{
    Node T[2 * S];
    int lazy[2 * S] = {};
    void init(int node, int s, int e){
        if(s == e){
            T[node] = {0, 0, 0, 1, 1, 1, 1};
            return;
        }
        int lch = 2 * node, rch = 2 * node + 1, m = (s + e) / 2;
        init(lch, s, m);
        init(rch, m + 1, e);
        T[node] = T[lch] + T[rch];
    }
    void propagate(int node, int s, int e){
        int lch = 2 * node, rch = 2 * node + 1;
        if(s != e){
            lazy[lch] += lazy[node], lazy[rch] += lazy[node];
        }
        T[node].l += lazy[node];
        T[node].r += lazy[node];
        T[node].mn += lazy[node];
        lazy[node] = 0;
    }
    void update(int node, int s, int e, int l, int r, int v){
        propagate(node, s, e);
        if(e < l || s > r) return;
        if(l <= s && e <= r){
            lazy[node] += v;
            propagate(node, s, e);
            return;
        }
        int lch = 2 * node, rch = 2 * node + 1, m = (s + e) / 2;
        update(lch, s, m, l, r, v);
        update(rch, m + 1, e, l, r, v);
        T[node] = T[lch] + T[rch];
    }
    int query(){
        return (T[1].mn == 0 ? T[1].d : 0);
    }
};
SegTree ST;
struct Line{
    int y1, y2, c;
};
vector<Line> L[1000005], R[1000005];
int M, N, P, B;

int main(){
    cin.tie(0) -> sync_with_stdio(false);
   
    cin >> M >> N >> B >> P;
    for(int i = 1; i <= P; i++){
        int x1, y1, x2, y2, c;
        if(B == 0) c = 1;
        cin >> x1 >> y1 >> x2 >> y2 >> c;
        L[x1].push_back({y1, y2, c});
        R[x2].push_back({y1, y2, c});
    }
    int ans = 0;
    int S = 1, E = 1;
    ST.init(1, 1, N);
    for(auto i : L[1]) ST.update(1, 1, N, i.y1, i.y2, i.c);
    while(S <= E && E <= M){
        int v = ST.query();
        if(v >= E - S + 1){
            ans = max(ans, E - S + 1);
            E++;
            for(auto i : R[E]) ST.update(1, 1, N, i.y1, i.y2, i.c);
        } else {
            S++;
            for(auto i : L[S]) ST.update(1, 1, N, i.y1, i.y2, i.c);
        }
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 55364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 55416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 55508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 56396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 62780 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 71 ms 112956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 113012 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 56748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 63804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 120 ms 114836 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 138 ms 115196 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 138 ms 115532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 624 ms 125988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 851 ms 131124 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1095 ms 135844 KB Output isn't correct
2 Halted 0 ms 0 KB -