Submission

Status:

[PPPPPPPPPPPPPPPPPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: exoworldgd

Problemset: วันว่างๆ

Language: cpp

Time: 0.014 second

Submitted On: 2026-03-28 01:56:36

#pragma GCC optimize("Ofast,unroll-loops,inline,fast-math,omit-frame-pointer")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt,tune=native,fma")
#include<bits/stdc++.h>
#define int long long
#define exoworldgd cin.tie(0)->sync_with_stdio(0),cout.tie(0)
using namespace std;
int q,n,l,r,e=-1,o,c;
map<int,int>mp;
signed main(void){
    exoworldgd;
    cin>>q;
    while(q--){
    	cin>>n;
    	while(n--)cin>>l>>r,mp[l]++,mp[r]--;
	}
	for(auto[l,r]:mp){
		if(!c&&e^-1)cout<<e<<' '<<l<<' ',o=1;
		c+=r,e=l;
	}
	if(!o)cout<<-1;
}