Submission
Status:
[PPPPPPPPPPPPPPPPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: VggT
Problemset: วันว่างๆ
Language: cpp
Time: 0.029 second
Submitted On: 2026-03-13 21:32:16
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n; cin >> n;
vector<pair<int,int>> ans;
map<int,int> m;
int busy = 0, start = -1;
for(int i = 0; i < n; i+=1)
{
int num; cin >> num;
for(int j = 0; j < num; j+=1)
{
int n1,n2; cin >> n1 >> n2;
m[n1]+=1;
m[n2]-=1;
}
}
for(auto a : m)
{
if(busy == 0 && start != -1)
{
ans.push_back({start,a.first});
}
busy+=a.second;
if(busy == 0)
{
start=a.first;
}
}
if(ans.empty()) cout << -1;
else
{
for(auto a : ans)
{
cout << a.first << ' ' << a.second << ' ';
}
}
return 0;
}