Educational Codeforces Round 46 C - Covered Points Count

时间:2023-03-10 04:20:08
Educational Codeforces Round 46 C - Covered Points Count

C - Covered Points Count

emmm 好像是先离散化一下 注意 R需要+1 这样可以确定端点

emmm 扫描线?瞎搞一下?

#include<bits/stdc++.h>
using namespace std;
#define maxn 4000005
#define LL long long
LL  a[maxn],b[maxn],ll[maxn],rr[maxn],c[maxn];
LL  x[maxn],y[maxn];
vector<LL >q;
int main(){
   LL  n;
   cin>>n;
   ;j<n;j++){
      cin>>a[j]>>b[j];
      b[j]++;
      q.push_back(a[j]);
      q.push_back(b[j]);
   }
   q.push_back();
   sort(q.begin(),q.end());
   q.erase(unique(q.begin(),q.end()),q.end());
   ;j<n;j++){
      LL  i=lower_bound(q.begin(),q.end(),a[j])-q.begin();
      LL  k=lower_bound(q.begin(),q.end(),b[j])-q.begin();
      //x[j]=i,y[j]=k;
      ll[i]++;
      rr[k]++;
   }
   LL  ans=;
   LL  i=;
   memset(c,,sizeof(c));
   memset(y,,sizeof(y));
   ;j<q.size();j++){
      ) x[j]+=ll[j]-rr[j];
      ];
     // cout<<x[j]<<endl;
   }
   ;j<q.size()-;j++){
     // cout<<x[j]<<" "<<q[j+1]<<" "<<q[j]<<endl;
      y[x[j]]+=q[j+]-q[j];
   }
   ;j<=n;j++){
     cout<<y[j]<<" ";
   }
   cout<<endl;
}