Cod sursa(job #3293143)
| Utilizator | Data | 10 aprilie 2025 14:04:31 | |
|---|---|---|---|
| Problema | Heapuri cu reuniune | Scor | 30 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.72 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("mergeheap.in");
ofstream fout("mergeheap.out");
int n, tt;
struct Iris {
priority_queue<int> pq;
}v[103];
int main()
{
fin >> n >> tt;
while(tt--) {
int tip; fin >> tip;
if(tip == 1) {
int m, x; fin >> m >> x;
v[m].pq.push(x);
}
else if(tip == 2) {
int m; fin >> m;
fout << v[m].pq.top() << '\n';
v[m].pq.pop();
}
else {
int a, b; fin >> a >> b;
while(!v[b].pq.empty()) {
v[a].pq.push(v[b].pq.top());
v[b].pq.pop();
}
}
}
return 0;
}
