Submission

Status:

[PPP-SSSSSSSSSSSSSSSSSSSSS]

Subtask/Task Score:

{0/100}

Score: 0

User: devilpoohs

Problemset: วันว่างๆ

Language: cpp

Time: 0.002 second

Submitted On: 2026-03-05 21:41:42

#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int m;
    vector<pair<int,int>> v;
    for(int i=0;i<n;i++){
        cin>>m;
        int s,e;
        for(int i=0;i<m;i++){
            cin>>s>>e;
            v.emplace_back(s,1);
            v.emplace_back(e,-1);
        }
    }
    sort(v.begin(),v.end());
    int t=0;
    bool chk=false;
    // vector<int> ans;
    bool chk2=false;
    for(auto&i:v){
        t+=i.second;
        if(chk==true){
            cout<<i.first<<' ';
            chk=false;
        }
        if(t==0 and i.first!=v.back().first){
            cout<<i.first<<' ';
            chk=true;
            chk2=true;
        }
    }
    if(chk2==false){
        cout<<-1;
    }
    return 0;
}