Pagini recente » Cod sursa (job #2161393) | Cod sursa (job #810383) | Cod sursa (job #2510311) | Cod sursa (job #2367905) | Cod sursa (job #2749221)
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define imax INT_MAX
#define llmax LLONG_MAX
#define sz(x) (int((x).size()))
#define start ios_base::sync_with_stdio(false), cin.tie(0)
#define finish fin.close(), fout.close()
using ll = long long;
using uint = unsigned int;
const string filename = "file";
fstream fin(filename + ".in");
ofstream fout(filename + ".out");
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
int n, t;
int main()
{
start;
int op, x, y;
fin >> n >> t;
vector<__gnu_pbds::priority_queue<int, less<int>, pairing_heap_tag> > q(n + 1);
while(t--)
{
fin >> op;
if(op == 1)
{
fin >> x >> y;
q[x].push(y);
}
else if(op == 2)
{
fin >> x;
fout << q[x].top() << '\n';
q[x].pop();
}
else
{
fin >> x >> y;
q[x].join(q[y]);
}
}
finish;
return 0;
}