Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int suma;
- struct Tree
- {
- int sz = 1;
- vector<int> t;
- Tree(int n)
- {
- while (sz < n)
- sz *= 2;
- t.resize(sz * 2);
- }
- int zwsuma (int l, int r)
- {
- l += sz;
- r += sz;
- suma = t[l] + t[r];
- while (l / 2 != r / 2)
- {
- if (l % 2 == 0)
- suma += + t[l + 1];
- if (r % 2 == 1)
- suma += t[r - 1];
- l /= 2;
- r /= 2;
- }
- return suma;
- }
- void zmien (int v, int z) // zmień jedną liczbę
- {
- v += sz;
- t[v] = z;
- while (v > 0)
- {
- v /= 2;
- t[v] = t[v / 2] + t[v / 2 + 1];
- }
- }
- };
- int main()
- {
- // ios_base::sync_with_stdio(0);
- // cin.tie(0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement