Cod sursa(job #2742061)
| Utilizator | Data | 20 aprilie 2021 00:05:11 | |
|---|---|---|---|
| Problema | Heapuri cu reuniune | Scor | 30 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.69 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin( "mergeheap.in" );
ofstream fout( "mergeheap.out" );
int N, M;
vector <priority_queue<int> > Q(101);
int main()
{
fin >> N >> M;
for( int i = 1; i <= M; ++i ) {
int tip, x, y;
fin >> tip;
if( tip != 2 ) fin >> x >> y;
else fin >> x;
if( tip == 1 )
Q[x].push( y );
if( tip == 2 ) {
fout << Q[x].top() << '\n';
Q[x].pop();
}
if( tip == 3 ) {
while( Q[y].size() > 0 ) {
Q[x].push( Q[y].top() );
Q[y].pop();
}
}
}
return 0;
}
