Copy the code newint.h from line 9 to 75 to Label 1
Here is the basic format of the Custom_heap
Custom_heap<T> name; //T is a typename.
Here is a example.
Custom_heap<int> hp;
(The type of x is T.)
Use the function set_compare_mode(m) to set the compare mode.
hp.set_compare_mode(0); //mode=0 -> the value of the top is mininum. //otherwise -> the value of the top is maxinum.
Use the function push(x) to push an element into the queue.
hp.push(0); hp.push(1);
Use the function front() to get the front element the queue.
hp.front(); //type T
Use the function pop() to pop the front element the queue.
hp.pop();
Here is the basic format of the Custom_heap
DisjointSet djs(s); //s is the size of djs.
Here is a example.
DisjointSet(123);
(x, y <= s)
Use the function find(x) to find the root of the node x.
cout << djs.find(0); //int cout << djs.find(1); //int
Use the function merge(x, y) to merge the set x and y.
djs.merge(x, y);
Use the function inset(x, y) to check if x and y are in the same set.
cout << djs.inset(x, y); //bool
Use the function unique_count() to count the different roots.
cout << djs.unique_count(); //int