UnstoppableSolveMachine's blog

By UnstoppableSolveMachine, 15 months ago, In English,


Hello, I would like to introduce the plugin FastOlympicCoding for Sublime Text.
It provides several useful features for competitive programming.

Read more »

  • Vote: I like it
  • +244
  • Vote: I do not like it

By UnstoppableSolveMachine, history, 21 month(s) ago, translation, In English,

I invent method to merge two cartesian trees with maybe intersect keys. And want to know what is asymptotic of it.


let's add to a standard cartesian tree field musorka

struct Node {
  Node *l = NULL, *r = NULL;
  int key, priority, cnt = 1;

  Node *musorka = NULL;

and when we want to merge trees A and B A->musorka = B

then write push

void push(Node *node) {
  if (!node->musorka) return;

  pair<Node*, Node*> spl = split(node->musorka, node->key);
  pair<Node*, Node*> spl2 = split(spl.second, node->key + 1);
  if (spl2.first) {

  node->l->musorka = spl.first;
  node->r->musorka = spl2.second;
  node->musorka = NULL;

then add this push to merge and split.

Maybe someone can estimate asimptotic of this or give counter test where it works n^2?

Read more »

  • Vote: I like it
  • +26
  • Vote: I do not like it