Submission
Status:
[PPPPPPPPPPPPPPPPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: asamarum70
Problemset: วันว่างๆ
Language: cpp
Time: 0.025 second
Submitted On: 2025-12-12 01:29:28
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,a,b,c) for(int i = a;i<b;i+=c)
#define fre(i,a,b,c) for(int i = a;i>=b;i-=c)
#define fs first
#define sc second
#define all(a) a.begin(),a.end()
#define IINF 2000000005
#define LINF 1000000000000000005
#define MOD 1000000007
#define str string
#define endl '\n'
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int uid(int a, int b) { return uniform_int_distribution<int>(a,b)(rng); }
ll uld(ll a, ll b) { return uniform_int_distribution<ll>(a,b)(rng); }
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int n;cin >> n;
vector<pii> e;
fr(i,0,n,1){
int m;cin >> m;
fr(j,0,m,1){
int l,r;cin >> l >> r;
e.push_back({l,0});
e.push_back({r,1});
}
}
int cnt = 0;
bool f = 0;
sort(e.begin(),e.end());
vector<int> ans;
for(auto [i,x] : e){
if(x) cnt--;
// cout << i << ' ' << x << endl;
if(cnt == 0){
f = 1;
ans.push_back(i);
}
if(!x)cnt++;
}
fr(i,1,ans.size() - 1,1)cout << ans[i] << ' ';
if(ans.size() <= 2)cout << -1;
}