#include <iostream> #include <algorithm> #include <map> #include <vector> #include <string> using namespace std; struct Node { int val, key, sz; Node * left, * right; Node(int value): val(value), key(rand()), sz(1), left(nullptr), right(nullptr) {} }; typedef Node * Pnode; int size(Pnode root) { if (!root) { return 0; } return root->sz; } void update(Pnode & root) { if(root) root->sz = size(root->left) + size(root->right) + 1; } void merge(Pnode & t, Pnode l, Pnode r) { if (!l || !r) t = l ? l : r; else if (l->key > r->key) merge(l->right, l->right, r), t = l; else merge(r->left, l, r->left), t = r; update(t); } void split(Pnode t, Pnode & l, Pnode & r, int key, int add = 0) { if (!t) return void(l = r = 0); int cur_key = add + size(t->left); // вычисляем неявный ключ if (key <= cur_key) split(t->left, l, t->left, key, add), r = t; else split(t->right, t->right, r, key, add + 1 + size(t->left)), l = t; update(t); } void push(Pnode & root, int k) { Pnode a(k); merge(root, root, a); } int main() { int n, k; cin >> n >> k; Pnode g(1); for (int i = 2; i <= n; i++) { push(g, i); } for (int i = 1; i <= n; i++) { push(g, i); } } 
  • Error in the transmission of the number 1 to the constructor - robivirt123
  • Pnode you have a pointer to Node. In an expression of type Pnode g(1) you are trying to initialize the pointer with value 1. You do not have a Node , you need to create it - for example, Pnode g = new Node(1); - Harry
  • Thank! Tupanul - robivirt123

0