Submission

Status:
[PPPPPPPPPPPPPPPPPPPPPPPPP]

Score: 100

User: Nathlol2

Problemset: วันว่างๆ

Language: cpp

Time: 0.011 second

Submitted On: 2025-03-25 20:25:21

#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define tiii tuple<int, int, int>
#define ar array
#define vi vector<int>
#define vll vector<long long>
#define mii map<int, int>
#define si set<int>
#define sc set<char>
#define ff first
#define ss second
#define rep(i,s,e) for(long long int i=s;i<e;i++)
#define cf(i,s,e) for(long long int i=s;i<=e;i++)
#define rf(i,e,s) for(long long int i=e;i>=s;i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
template <class T>
void print_v(vector<T> &v) { for (auto x : v) cout << x << " "; cout << "\n"; }
#define MX INT_MAX
#define MN INT_MIN
#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define read(type) readInt<type>()
ll min(ll a,int b) { if (a<b) return a; return b; }
ll min(int a,ll b) { if (a<b) return a; return b; }
ll max(ll a,int b) { if (a>b) return a; return b; }
ll max(int a,ll b) { if (a>b) return a; return b; }
ll gcd(ll a,ll b) { if (b==0) return a; return gcd(b, a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
string to_upper(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A'; return a; }
string to_lower(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A'; return a; }
bool prime(ll a) { if (a==1) return 0; for (int i=2;i<=round(sqrt(a));++i) if (a%i==0) return 0; return 1; }
void YY() { cout<<"YES\n"; }
void NN() { cout<<"NO\n"; }
void Yes() { cout<<"Yes\n"; }
void No() { cout<<"No\n"; }
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
vi c(1001, 0);
int mx = MN;
int mn = MX;
void solve(){
    int n;
    cin >> n;
    rep(i, 0, n){
        int x;
        cin >> x;
        int a, b;
        rep(j, 0, x){
            cin >> a >> b;
            c[a]--;
            c[b]++;
            mn = min(mn, a);
            mx = max(mx, b);
        }
    }
    vi ans;
    int s = 0;
    bool f = true;
    rep(i, mn, mx){
        s += c[i];
        if(s < 0 && !f){
            ans.pb(i);
            f = true;
        }
        if(s == 0 && f){
            ans.pb(i);
            f = false;
        }
    }
    if(ans.size()){
        print_v(ans);
    }else{
        cout << "-1\n";
    }
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tc = 1;
    //cin >> tc;
    while(tc--){
        solve();
    }
}