Submission #422372

# Submission time Handle Problem Language Result Execution time Memory
422372 2021-06-10T05:03:44 Z lyc Food Court (JOI21_foodcourt) C++14
0 / 100
499 ms 28648 KB
#include <bits/stdc++.h>
using namespace std;

#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long ll;

const int mxN = 250005;
const int mxM = 250005;
const int mxQ = 250005;

int N, M, Q;
int group[mxM];

struct node {
    int s, e, m;
    ll vsum; bool vmax;
    node *l, *r;
    node(int s, int e): s(s), e(e), m((s+e)/2), vsum(0), vmax(0) {
        if (s != e) {
            l = new node(s,m);
            r = new node(m+1,e);
        }
    }

    void pushdown() {
        if (vmax) {
            if (vsum < 0) {
                if (s != e) {
                    l->vsum += vsum;
                    r->vsum += vsum;
                }
                vsum = 0;
            }

            if (s != e) {
                l->vmax = r->vmax = 1;
            }
            vmax = 0;
        }
    }

    void uadd(int a, int b, int c) {
        pushdown();
        if (a <= s && e <= b) {
            vsum += c;
        } else {
            if (a <= m) l->uadd(a,b,c);
            if (b > m) r->uadd(a,b,c);
        }
    }

    void umax(int a, int b) {
        pushdown();
        if (a <= s && e <= b) {
            vmax = 1;
        } else {
            if (a <= m) l->umax(a,b);
            if (b > m) r->umax(a,b);
        }
    }

    ll qsum(int a) {
        pushdown();
        //assert(vsum >= 0);
        ll ret = vsum;
        if (s != e) {
            if (a <= m) ret += l->qsum(a);
            else ret += r->qsum(a);
        }
        return ret;
    }

} *root;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);

    cin >> N >> M >> Q;
    root = new node(1,N);
    FOR(i,1,Q){
        int T, L, R, C, K, A;
        long long B;
        cin >> T;
        if (T == 1) {
            cin >> L >> R >> C >> K;
            root->uadd(L,R,K);
        } else if (T == 2) {
            cin >> L >> R >> K;
            root->uadd(L,R,-K);
            root->umax(L,R);
        } else {
            cin >> A >> B;
            int res = root->qsum(A) >= B ? 1 : 0;
            cout << res << '\n';
        }
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 97 ms 8476 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 499 ms 28648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 63 ms 8192 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -