Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- #include <queue>
- #include <algorithm>
- using namespace std;
- int n,a,b,c,d,p=0;
- pair <pair <int,int>,int> pocz[500005];
- pair <pair <int,int>,int> kon[500005];
- priority_queue <pair<int,int> >q;
- int t[500005][2];
- int main(){
- scanf("%d",&n);
- for(int i=1;n>=i;i++)
- {
- scanf("%d%d%d%d",&a,&b,&c,&d);
- pocz[i-1].first.first=a;
- pocz[i-1].first.second=c;
- kon[i-1].first.first=b;
- kon[i-1].first.second=d;
- pocz[i-1].second=i;
- kon[i-1].second=i;
- }
- sort(pocz,pocz+n);
- sort(kon,kon+n);
- for(int i=1;n>=i;i++)
- {
- while(pocz[p].first.first==i)
- {
- q.push({pocz[p].first.second*-1,pocz[p].second});
- p++;
- }
- pair <int,int> s=q.top();
- q.pop();
- t[s.second][0]=i;
- }
- p=0;
- for(int i=1;n>=i;i++)
- {
- while(kon[p].first.first==i)
- {
- q.push({kon[p].first.second*-1,kon[p].second});
- p++;
- }
- pair <int,int> s=q.top();
- q.pop();
- t[s.second][1]=i;
- }
- for(int i=1;n>=i;i++)
- printf("%d %d\n",t[i][0],t[i][1]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement