Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pii find_pos(int pos)
- {
- int bl = 0;
- for (auto x : q)
- {
- if (pos >= x.size())
- pos -= x.size(), ++bl;
- else
- return mk(bl, pos);
- }
- }
- void add_block_build(int pos)
- {
- q.inb(a);
- if (pos)
- {
- ll x = q[pos - 1].back();
- q[pos - 1].pop_back();
- q[pos].inb(x);
- }
- }
- void add_block(int pos)
- {
- vll sw;
- int sz = q[pos - 1].size();
- for (int i = sz - 1; i >= sz / 2; --i)
- {
- sw.inb(q[pos - 1].back());
- q[pos - 1].pop_back();
- }
- reverse(all(sw));
- q.insert(q.begin() + pos, sw);
- }
- void add_x(ll x)
- {
- q.back().inb(x);
- ANS += x * x;
- if (q.back().size() == LEN)
- add_block_build(q.size());
- }
- void delete_block(int pos)
- {
- q.erase(q.begin() + pos);
- }
Add Comment
Please, Sign In to add comment