Submission #953164

# Submission time Handle Problem Language Result Execution time Memory
953164 2024-03-25T15:13:33 Z FaresSTH Sterilizing Spray (JOI15_sterilizing) C++17
10 / 100
91 ms 5456 KB
#pragma GCC optimize("O3,Ofast,unroll-loops")
#include "bits/stdc++.h"
const int MOD = 1e9 + 7;
using namespace std;
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define ll long long
#define S second
#define F first
vector<ll> tree;
ll N;
 
void init(ll n) {
    N = 1 << (ll)ceil(log2(n));
    tree.resize(N * 2, 0);
}
 
void upd(ll id, ll val) {
    id += N;
    tree[id] = val;
    while (id /= 2) {
        tree[id] = tree[id * 2] + tree[id * 2 + 1];
    }
}
 
ll query(ll id, ll l, ll r, ll s, ll e) {
    if (s <= l && r <= e) return tree[id];
    if (l > e || r < s) return 0;
    ll m = (l + r) / 2;
    return query(id * 2, l, m, s, e) + query(id * 2 + 1, m + 1, r, s, e);
}
 
void solve() {
    ll n, q, k;
    cin >> n >> q >> k;
    ll val; init(n);
    for (ll i = 0; i < n; i++) {
        cin >> val;
        upd(i, val);
    }
 
    while (q--) {
        ll s, t, u;
        cin >> s >> t >> u;
        if (s == 1) upd(t - 1, u);
        if (s == 3) cout << query(1, 0, N - 1, t - 1, u - 1) << endl;
    }
}
 
int main() {
    cin.tie(0)->sync_with_stdio(0);
    int t = 1;
    // cin >> t;
    while (t--) solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 71 ms 3668 KB Output is correct
2 Correct 65 ms 3392 KB Output is correct
3 Correct 56 ms 4436 KB Output is correct
4 Correct 65 ms 4856 KB Output is correct
5 Correct 81 ms 5316 KB Output is correct
6 Correct 79 ms 5204 KB Output is correct
7 Correct 80 ms 5204 KB Output is correct
8 Correct 91 ms 5436 KB Output is correct
9 Correct 75 ms 5204 KB Output is correct
10 Correct 76 ms 5064 KB Output is correct
11 Correct 82 ms 5456 KB Output is correct
12 Correct 75 ms 5204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 3152 KB Output isn't correct
2 Halted 0 ms 0 KB -