#include #include #include #include #include #include #include #include #include using namespace std; template void print(vector sez) { for (T x : sez) cout << x << " "; cout << endl; } class BinaryHeap { public: vector t={-1}; void push(int x) { t.push_back(x); int i=t.size()-1; while (i>1 && t[i] next; SkipNode(int _value, int _height) : value(_value), height(_height) { next.resize(height); } }; class SkipList { int max_height; SkipNode *head; default_random_engine rnd; public: SkipList() : max_height(20) { head = new SkipNode(-1, max_height); rnd = default_random_engine(123); } ~SkipList() { delete head; } bool contains(int x) { SkipNode *node = head; for (int h=max_height-1; h>=0; h--) { while (node->next[h]!=NULL && node->next[h]->value < x) node = node->next[h]; } return node->next[0]!=NULL && node->next[0]->value == x; } void insert(int x) { int height=1; while (height=0; h--) { while (node->next[h]!=NULL && node->next[h]->value < x) node = node->next[h]; if (hnext[h] = node->next[h]; node->next[h] = new_node; } } } }; int main() { default_random_engine rnd(123); SkipList sl; int n=100'000, st=0; for (int i=0;i sez; for (int i=0;i