Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2.  
  3. #include <iostream>
  4. #include <cstdio>
  5. #include <string>
  6. #include <cmath>
  7. #include <algorithm>
  8. #include <set>
  9.  
  10. using namespace std;
  11.  
  12. const int maxx = int(1e9) + 10;
  13.  
  14. struct node {
  15.     node* left;
  16.     node* right;
  17.     int key;
  18.     int prio;
  19.     node() {
  20.         left = NULL;
  21.         right = NULL;
  22.     }
  23. };
  24.  
  25. pair<node*, node*> split(int arg, node* t) {
  26.     pair <node*, node*> res;
  27.     res.first = NULL;
  28.     res.second = NULL;
  29.     if (t == NULL) {
  30.         return res;
  31.     }
  32.     if (arg >= (*t).key) {
  33.         res.first = t;
  34.         pair<node*, node*> buf;
  35.         buf = split(arg, (*t).right);
  36.         (*t).right = buf.first;
  37.         res.second = buf.second;
  38.     }
  39.     else {
  40.         res.second = t;
  41.         pair<node*, node*> buf;
  42.         buf = split(arg, (*t).left);
  43.         (*t).left = buf.second;
  44.         res.first = buf.first;
  45.     }
  46.     return res;
  47. }
  48.  
  49. // PRE: this.key < with.key
  50. node* merge(node* a, node* b) {
  51.     if (a = NULL) {
  52.         return b;
  53.     }
  54.     if (b == NULL) {
  55.         return a;
  56.     }
  57.     if ((*a).prio > (*b).prio) {
  58.         (*a).right = merge((*a).right, b);
  59.         return a;
  60.     }
  61.     else {
  62.         (*b).left = merge(a, (*b).left);
  63.         return b;
  64.     }
  65. }
  66.  
  67. int main()
  68. {
  69.     //freopen("input.txt", "r", stdin);
  70.     //freopen("output.txt", "w", stdout);
  71.    
  72.     return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement