Advertisement
LZsolar

SMMR-236: Missing Skyline

Jun 26th, 2020
1,936
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long int ll;
  4. typedef pair<ll,pair<ll,ll>> pii;
  5. int main(){
  6.    
  7.     ll n;
  8.     priority_queue<pii,vector<pii>,greater<pii>> q;
  9.     //2out 1in
  10.     scanf("%lld",&n);
  11.     for(ll i=0;i<n;i++){
  12.         ll a,b,x;
  13.         scanf("%lld %lld %lld",&a,&b,&x);
  14.        
  15.         q.push({a,{1,-x}});
  16.         q.push({b,{2,x}});
  17.     }
  18.    
  19.     ll now_H=-99;
  20.     multiset<ll> sett;
  21.     sett.insert(0);
  22.     while(!q.empty()){
  23.         ll now=q.top().first,  x=q.top().second.first, h=q.top().second.second;
  24.         q.pop();
  25.         //printf("[%lld %lld %lld]\n",now,x,h);
  26.         if(x==1){
  27.             sett.insert(-h);
  28.         }
  29.         else{
  30.             sett.erase(sett.find(h));
  31.         }
  32.         auto itr = sett.end();
  33.         itr--;
  34.         if(*itr!=now_H){
  35.             printf("%lld %lld\n",now,*itr);
  36.             now_H=*itr;
  37.         }
  38.        
  39.     }
  40.    
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement