// 将所有存在交集的区间合并
void Merge(vector<PII>& segs)
{
sort(segs.begin(), segs.end());
vector<PII> ans;
int st = -2e9, ed = -2e9;
for(auto& seg : segs)
{
if (ed < seg.first)
{
if (st != -2e9) ans.push_back({st, ed});
st = seg.first, ed = seg.second;
}
else ed = max(ed, seg.second);
}
if (st != -2e9) ans.push_back({st, ed});
segs = ans;
}