Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define F first
- #define S second
- #define pb push_back
- #define mp make_pair
- using namespace std;
- struct pair_comp {
- bool operator() (pair<int,pair<int,int>> const & a, pair<int,pair<int,int>> const & b) {
- return (a.F < b.F) || (a.F == b.F && a.S.F < b.S.F) || (a.F == b.F && a.S.F == b.S.F && a.S.S > b.S.S);
- }
- };
- int l, h, r;
- vector<pair<int,pair<int,int>>>pt;
- multiset<int>q;
- int main() {
- // freopen("input.txt", "r", stdin);
- while(scanf("%d%d%d", &l, &h, &r) == 3) {
- pt.pb(mp(l, mp(0, h)));
- pt.pb(mp(r, mp(1, h)));
- }
- sort(pt.begin(), pt.end(), pair_comp());
- if (pt[0].F > 1)
- printf("1 0 ");
- q.insert(0);
- for (int i = 0; i < pt.size(); i++) {
- if (i && pt[i].S.F == 1 && pt[i-1].S.F == 1 && pt[i].F == pt[i-1].F && pt[i].S.S <= pt[i-1].S.S) {
- q.erase(pt[i].S.S);
- continue;
- }
- if (pt[i].S.F == 0) {
- if (pt[i].S.S > *q.rbegin())
- printf("%d %d ", pt[i].F, pt[i].S.S);
- q.insert(pt[i].S.S);
- } else {
- q.erase(pt[i].S.S);
- if (*q.rbegin() >= pt[i].S.S)
- continue;
- if (i + 1 < pt.size())
- printf("%d %d ", pt[i].F, *q.rbegin());
- else
- printf("%d %d\n", pt[i].F, *q.rbegin());
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement