Cod sursa(job #2749224)

Utilizator QwertyDvorakQwerty Dvorak QwertyDvorak Data 5 mai 2021 22:17:16
Problema Heapuri cu reuniune Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.59 kb
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

using namespace std;
using namespace __gnu_pbds;

ifstream fin("mergeheap.in");
ofstream fout("mergeheap.out");

int n, t, x, y, z;

int main()
{
	cin >> n >> t;
	vector<__gnu_pbds::priority_queue<int,less<int>, pairing_heap_tag> > q(n + 1);
	while(t--)
	{
		fin >> x >> y;
		if(z == 1)
		{
			fin >> z;
			q[y].push(z);
		}
		else if(x == 2)
		{
			fout << q[y].top() << "\n";
			q[y].pop();
		}
		else
		{
			fin >> z;
			q[y].join(q[j]);
		}
	}
	return 0;
}