Submission
Status:
[PPPPPPPPPPPPPPPPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: theem1502
Problemset: วันว่างๆ
Language: cpp
Time: 0.045 second
Submitted On: 2026-02-20 23:45:51
#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int,int> first, pair<int,int> second) {
if (first.first > second.first) {
return false;
}
if (first.first < second.first) {
return true;
}
if (first.second > second.second) {
return true;
}
return false;
}
int main() {
int num;
cin >> num;
// vector<>
vector<pair<int,int>> sweep;
for (int i = 0; i < num; i++) {
int a;
cin >> a;
for (int j = 0; j < a; j++) {
int tempa, tempb;
cin >> tempa >> tempb;
// thearray[i].push_back(make_pair(tempa, tempb));
sweep.push_back(make_pair(tempa, 1));
sweep.push_back(make_pair(tempb, -1));
}
}
sort(sweep.begin(), sweep.end(), comp);
int counter = 0;
bool thebool = false;
for (int i = 0; i < sweep.size()-1; i++) {
counter += sweep[i].second;
if (counter == 0 && i < sweep.size()) {
/*
if (sweep[i+1].first == 0) {
continue;
}
*/
thebool = true;
cout << sweep[i].first << " " << sweep[i+1].first << " ";
}
}
if (thebool == false) {
cout << -1;
}
}