Submission #520871

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

const int S = (1 << 21);
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[400005], R[400005];
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;
        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 16 ms 35532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 35432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 35536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 36428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 42772 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 146 ms 188444 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 56 ms 76692 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 36704 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 52 ms 43936 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 62 ms 80368 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 55 ms 77384 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 62 ms 77636 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 65 ms 78496 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 55 ms 78400 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 63 ms 82440 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -