Pagini recente » Cod sursa (job #1128474) | Cod sursa (job #788116) | Cod sursa (job #1903702) | Cod sursa (job #3128362) | Cod sursa (job #2906137)
#include <iostream>
#include <fstream>
#include <queue>
using namespace std;
ifstream f("mergeheap.in");
ofstream g("mergeheap.out");
priority_queue <unsigned int> h[101];
int N,Q,operatie,a,b,i;
int main()
{
f>>N>>Q;
for(i=0; i<Q; ++i)
{
f>>operatie;
if(operatie==1)
{
f>>a>>b;
h[a].push(b);
}
if(operatie==2)
{
f>>a;
g<<h[a].top()<<"\n";
h[a].pop();
}
if(operatie==3)
{
f>>a>>b;
while(!h[a].empty())
{
h[b].push(h[a].top());
h[a].pop();
}
}
}
return 0;
}