Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <cstdio>
- #include <string>
- #include <cmath>
- #include <algorithm>
- #include <set>
- using namespace std;
- const int maxx = int(1e9) + 10;
- struct node {
- node* left;
- node* right;
- int key;
- int prio;
- node() {
- left = NULL;
- right = NULL;
- }
- };
- pair<node*, node*> split(int arg, node* t) {
- pair <node*, node*> res;
- res.first = NULL;
- res.second = NULL;
- if (t == NULL) {
- return res;
- }
- if (arg >= (*t).key) {
- res.first = t;
- pair<node*, node*> buf;
- buf = split(arg, (*t).right);
- (*t).right = buf.first;
- res.second = buf.second;
- }
- else {
- res.second = t;
- pair<node*, node*> buf;
- buf = split(arg, (*t).left);
- (*t).left = buf.second;
- res.first = buf.first;
- }
- return res;
- }
- // PRE: this.key < with.key
- node* merge(node* a, node* b) {
- if (a = NULL) {
- return b;
- }
- if (b == NULL) {
- return a;
- }
- if ((*a).prio > (*b).prio) {
- (*a).right = merge((*a).right, b);
- return a;
- }
- else {
- (*b).left = merge(a, (*b).left);
- return b;
- }
- }
- int main()
- {
- //freopen("input.txt", "r", stdin);
- //freopen("output.txt", "w", stdout);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement