Differential simple title set POJ 2155 Matrix (two-dimensional array of tree + differential)

 

[] One-dimensional differential Codeforces 1000C Covered Points Count 

Subject to the effect:

Given $ n-$ line segments, segment ($ l, r \ leq10 ^ {18} $) of these segments where given, these segments can cover the point where they contain ask you included $ [1, n] $ times the number of points respectively.

Problem-solving analysis:
a differential to an efficient statistics about the number of line segments to be covered within the specified range, at the same time, because the $ l, r $ size is very large, so we need all the discrete segments.

#include <bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T&x){        
    x=0;int f=1;char ch=getchar();
    while(ch<'0' ||ch>'9'){ if(ch=='-')f=-1; ch=getchar(); }
    while(ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
    x*=f;
}
#define REP(i,s,t) for(int i=s;i<=t;i++)
typedef long long ll;
map<ll,ll>mp;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    REP(i,1,n){
        ll l,r;read(l);read(r);
        Mp [L] Tasutasu, Mp [R Tasu 1 ] - ;
    }
    vector<ll>ans(n+10);
    last LL = 0 , sum = 0 ;     // the last end of a range of statistical index, sum and computing the prefix 
    for (E Auto: MP) {
        ans[sum]+=(e.first-last);      
        sum + = e.second;
        last=e.first;
    }
    REP(i,1,n)cout<<ans[i]<<" ";
}
View Code

 

 

 

[A] dimensional difference Codeforces 853B Jury Meeting (prefix + and differential)

 

 

 

 

[] Two-dimensional differential POJ 2155 Matrix (two-dimensional array of tree + differential)

 

 

 

 

[] Difference tree CodeForces 739B Alyona and a tree (differential binary tree +)

 

Guess you like

Origin www.cnblogs.com/00isok/p/10927070.html