Submission #397414

# Submission time Handle Problem Language Result Execution time Memory
397414 2021-05-02T06:13:08 Z phathnv Food Court (JOI21_foodcourt) C++11
21 / 100
496 ms 18952 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int N = 25e4 + 7;

struct SegTree{
    int n;
    ll d[N * 4], lazyVal[N * 4], lazyMax[N * 4];
    void init(int _n){
        n = _n;
    }
    void doLazy(int id, int l, int r){
        d[id] += lazyVal[id];
        d[id] = max(d[id], lazyMax[id]);
        if (l < r){
            lazyVal[id << 1] += lazyVal[id];
            lazyMax[id << 1] += lazyVal[id];
            lazyMax[id << 1] = max(lazyMax[id << 1], lazyMax[id]);
            lazyVal[id << 1 | 1] += lazyVal[id];
            lazyMax[id << 1 | 1] += lazyVal[id];
            lazyMax[id << 1 | 1] = max(lazyMax[id << 1 | 1], lazyMax[id]);
        }
        lazyVal[id] = lazyMax[id] = 0;
    }
    void update(int id, int l, int r, int u, int v, int val){
        doLazy(id, l, r);
        if (v < l || r < u)
            return;
        if (u <= l && r <= v){
            lazyVal[id] += val;
            doLazy(id, l, r);
            return;
        }
        int mid = (l + r) >> 1;
        update(id << 1, l, mid, u, v, val);
        update(id << 1 | 1, mid + 1, r, u, v, val);
    }
    ll get(int id, int l, int r, int pos){
        doLazy(id, l, r);
        if (pos < l || r < pos)
            return 0;
        if (l == r)
            return d[id];
        int mid = (l + r) >> 1;
        return max(get(id << 1, l, mid, pos), get(id << 1 | 1, mid + 1, r, pos));
    }
    void update(int l, int r, int k){
        update(1, 1, n, l, r, k);
    }
    ll get(int pos){
        return get(1, 1, n, pos);
    }
} st;

int n, m, q;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> q;
    assert(m == 1);
    st.init(n);
    while (q--){
        int t;
        cin >> t;
        if (t == 1){
            int l, r, c, k;
            cin >> l >> r >> c >> k;
            st.update(l, r, k);
        } else if (t == 2){
            int l, r, k;
            cin >> l >> r >> k;
            st.update(l, r, -k);
        } else {
            int pos;
            ll val;
            cin >> pos >> val;
            if (st.get(pos) >= val)
                cout << 1 << '\n';
            else
                cout << 0 << '\n';
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 376 ms 18108 KB Output is correct
2 Correct 280 ms 16964 KB Output is correct
3 Correct 407 ms 18712 KB Output is correct
4 Correct 326 ms 17172 KB Output is correct
5 Correct 290 ms 17244 KB Output is correct
6 Correct 460 ms 18864 KB Output is correct
7 Correct 101 ms 4600 KB Output is correct
8 Correct 96 ms 4564 KB Output is correct
9 Correct 404 ms 18896 KB Output is correct
10 Correct 389 ms 18888 KB Output is correct
11 Correct 398 ms 18760 KB Output is correct
12 Correct 475 ms 18752 KB Output is correct
13 Correct 395 ms 18952 KB Output is correct
14 Correct 484 ms 18728 KB Output is correct
15 Correct 416 ms 18696 KB Output is correct
16 Correct 403 ms 18652 KB Output is correct
17 Correct 407 ms 18736 KB Output is correct
18 Correct 496 ms 18744 KB Output is correct
19 Correct 420 ms 18740 KB Output is correct
20 Correct 431 ms 18708 KB Output is correct
21 Correct 429 ms 18744 KB Output is correct
22 Correct 420 ms 18916 KB Output is correct
23 Correct 430 ms 18764 KB Output is correct
24 Correct 418 ms 18628 KB Output is correct
25 Correct 369 ms 18360 KB Output is correct
26 Correct 335 ms 18492 KB Output is correct
27 Correct 316 ms 18496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -